I'm trying to retrieve data from firebase and I an using the guide given by firebase but I am not able to create the reference with my firebase database.
FIRDatabaseReference * ref = [[FIRDatabase alloc]
referenceFromURL:@"https://project-8326407164650950213.firebaseio.com"];
NSLog(@"%@",ref);
I am using this code to create the reference with my database but app crash.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'
I am new in iOS and first time using firebase. Please tell me the solution as I am going according to firebase guide.
I'm no firebase expert, but when you're working with a class in Obj-C, you'll either invoke its class methods (e.g. [FIRDatabase database]), or you'll first allocate and initialize it ([[FIRDatabase alloc] <an initializer>]), and secondly use an instance method on the instance.
In your code sample above, I see an alloc without an initializer, which makes me think you're missing something.
If I look at the iOS quick start, I see a call to initWithURL, which is one of the initializers.
Firebase *messagePath = [[Firebase alloc] initWithUrl:[NSString stringWithFormat:@"%@%@%@", MAIN_URL,MESSAGES_DIRECTORY,conversationId]];
[[messagePath queryLimitedToLast:10] observeEventType:FEventTypeChildAdded withBlock:^(FDataSnapshot *snapshot) {
NSMutableArray *messages = [[NSMutableArray alloc] init];
[messages addObject:snapshot.value];
observingBlock(true,messages);
}];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With