OK, so the error is being returned from -openDatabaseNamed:. Which certainly
seems to imply that the filesystem is inaccessible. Except that
NSFileProtectionCompleteUntilFirstUserAuthentication is documented as:
>> The file is stored in an encrypted format on disk and cannot be accessed
>> until after the device has booted. After the user unlocks the device for the
>> first time, your app can access the file and continue to access it even if
>> the user subsequently locks the device.
One possibility: you may be seeing an error where there is none, since your
error handling logic is incorrect:
> if (error && error.code == 401) {
>
> // ...trimmed...
>
> } else if (error || !self.couchDatabase) {
> NSLog(@"Error opening Tap Forms database: %@", error);
In Cocoa error handling, failure is signaled by the return value being nil (or
NO or whatever), not by the `error` result being non-nil. In fact the `error`
result is undefined unless the return value indicates an error. (This mistake
is easier to make nowadays with ARC; in the old days, an NSError* local
variable would be initialized to garbage, meaning that you’d likely crash if
you accessed it when it hadn’t been set.)
The code should be something like:
if (!self.couchDatabase) {
if (error.code == 401) {
…
} else {
NSLog(@"Error opening Tap Forms database: %@", error);
}
}
Try that and see if it helps.
—Jens
--
You received this message because you are subscribed to the Google Groups
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mobile-couchbase/5E3ACCCC-4827-41EF-B92F-3A500B899036%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.