salmancs43 salmancs43 - 2 years ago 578
Objective-C Question

Retrieve data from firebase in objective c

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]

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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download