Gibraltar
Gibraltar

Reputation: 1115

Where to add Firebase Database Reference in iOS Obj-C

I'm setting up a realtime database through Firebase and am confused where to put the following line of code:

self.ref = [[FIRDatabase database] reference];

These are the instructions I'm following: https://firebase.google.com/docs/database/ios/start

enter image description here

Upvotes: 1

Views: 2196

Answers (2)

Gaurav Kaitwade
Gaurav Kaitwade

Reputation: 31

Its simple, Just Add following line in your AppDelegate.h

@property (nonatomic, readonly, strong) FIRDatabaseReference * ref;// Property 

After adding,In your AppDelegate.m didFinishLaunchingWithOption Replace

self.ref = [[FIRDatabase database] reference];

With

_ref = [[FIRDatabase database] reference];  

Problem Solved.. :)

Upvotes: 3

Gibraltar
Gibraltar

Reputation: 1115

To address this, I added the following line under (at)interface in my App Delegate:

@property FIRDatabaseReference *ref;

Then I could add the following under didFinishLaunchingWithOptions:

self.ref = [[FIRDatabase database] reference];

Upvotes: 0

Related Questions