1

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

Gibraltar
  • 1,106
  • 9
  • 21
  • It says, once you've initialized Firebase, create a reference, which means, it should be the next line in your `didFinishLaunchingWithOption`. Whereas `ref` should be your class-property. – Adil Soomro Aug 15 '16 at 17:39
  • Thanks @AdilSoomro. How do I set up the class property? – Gibraltar Aug 15 '16 at 17:40
  • Here's apple documentation on using properties in Obj-C [Encapsulating Data](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/EncapsulatingData/EncapsulatingData.html) – Adil Soomro Aug 15 '16 at 17:43
  • Thanks again for the help. I added (at)property FIRDatabaseReference *ref; to the (at)interface section and it looks to be working. – Gibraltar Aug 15 '16 at 17:45
  • That's cool to know. Happy coding! – Adil Soomro Aug 15 '16 at 17:46

2 Answers2

3

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.. :)

0

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];
Gibraltar
  • 1,106
  • 9
  • 21