Hi Jens,
Hmmm. I am getting crash log that says it can be nil. here is the code
- (void) createDatabaseAndStartReplication:(NSArray*)groupIds {
NSError *__autoreleasing error;
for (NSString *groupId in groupIds) {
NSString *databaseName = [NSString stringWithFormat:@"group_%@",
groupId];
CBLDatabase *database = [self.server databaseNamed:databaseName
error:&error];
HubCredential *credInfo = [[HubCredentialService sharedInstance]
credInfo];
NSString *url;
if ([HubUserDefaults hubEmbedUserPassInReplicateURL]) {
url = [NSString stringWithFormat:@"%@%@",REMOTE_COUCH_DB_URL,
databaseName];
}
else {
url = [NSString stringWithFormat:@"%@%@",REMOTE_COUCH_DB_URL,
databaseName];
}
CBLReplication *pullRepl = [database createPullReplication:[NSURL
URLWithString:url]];
CBLReplication *pushRepl = [database createPushReplication:[NSURL
URLWithString:url]];
pullRepl.authenticator = [CBLAuthenticator basicAuthenticatorWithName
:credInfo.userName password:credInfo.password];
pushRepl.authenticator =[CBLAuthenticator basicAuthenticatorWithName
:credInfo.userName password:credInfo.password];
[self addReplications:@[pullRepl, pushRepl]];
[self setupPushFilters:database];
}
}
- (void) addReplications: (NSArray*)replications {
for (CBLReplication* repl in replications) {
[self addReplication: repl];
}
}
- (void) addReplication: (CBLReplication*)repl {
if (![self.replications containsObject: repl]) {
repl.continuous = YES;
[self.replications addObject:repl];
if (repl.pull) {
[self.pullReplications addObject:repl];
}
[repl start];
/*listen to all properties of all replications*/
[repl addObserver:self forKeyPath:@"status" options:(
NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld) context:NULL];
}
}
Here is the crash log
Thread : Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x183558f48 __exceptionPreprocess
1 libobjc.A.dylib 0x198a03f80 objc_exception_throw
2 CoreFoundation 0x1834421ec -[__NSPlaceholderArray
initWithObjects:count:]
3 CoreFoundation 0x18344dc94 +[NSArray
arrayWithObjects:count:]
4 my123app 0x1001ceb74 -[HubTouchDBService
createDatabaseAndStartReplication:] (HubTouchDBService.m:134)
5 my123app 0x10016e060 __33-[Authorization
signIn:password:]_block_invoke (Authorization.m:216)
6 my123app 0x10062433c __84-[AFHTTPSessionManager
dataTaskWithHTTPMethod:URLString:parameters:success:failure:]_block_invoke74
(AFHTTPSessionManager.m:250)
7 my123app 0x1006376fc
__72-[AFURLSessionManagerTaskDelegate
URLSession:task:didCompleteWithError:]_block_invoke_272
(AFURLSessionManager.m:194)
8 libdispatch.dylib 0x1992156e8
_dispatch_call_block_and_release
9 libdispatch.dylib 0x1992156a8 _dispatch_client_callout
10 libdispatch.dylib 0x19921adb0
_dispatch_main_queue_callback_4CF
11 CoreFoundation 0x1835101f8
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
12 CoreFoundation 0x18350e060 __CFRunLoopRun
13 CoreFoundation 0x18343cca0 CFRunLoopRunSpecific
14 GraphicsServices 0x18e9c0088 GSEventRunModal
15 UIKit 0x188b54ffc UIApplicationMain
16 simplyUs 0x1000af5a0 main (main.m:14)
17 libdyld.dylib 0x1992468b8 start
The line is is crashing on is this "[self addReplications:@[pullRepl,
pushRepl]];"
Herman
On Tuesday, December 1, 2015 at 12:22:40 PM UTC-5, Jens Alfke wrote:
>
>
> On Dec 1, 2015, at 9:11 AM, Herman Chan <[email protected] <javascript:>>
> wrote:
>
> I can see that [CBLDatabase createPullReplication] can return nil (mark
> nullable), when will that happen? Moreover, what should we do when that
> happens?
>
>
> It actually can’t; the ‘nullable’ annotation was a mistake. Fixed on the
> master branch.
>
> —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/6d1e2b72-c679-4fc8-93fe-e4eb3d2403df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.