Where to add Firebase Database Reference in iOS Obj-C

前端 未结 2 732
滥情空心
滥情空心 2021-01-25 16:11

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];


        
相关标签:
2条回答
  • 2021-01-25 16:52

    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 讨论(0)
  • 2021-01-25 17:05

    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];
    
    0 讨论(0)
提交回复
热议问题