从firebase数据库检索数据:代码没有进入完成块或错误块

我试图从数据库检索数据,但我的代码没有进入完成块或错误块。 我不想从用户进行任何身份validation身份validation,并从应用程序保存数据库中的数据。 只是想从数据库中检索数据。 我的数据库结构是这样的

在这里输入图像说明

这是代码

- (void)viewDidLoad { [FIRDatabase database].persistenceEnabled = YES; [self referenceFromURL:@"https://project-8326407164650950213.firebaseio.com"]; } - (FIRDatabaseReference *) referenceFromURL:(NSString *)databaseUrl{ commentsRef = [[FIRDatabase database] referenceFromURL:databaseUrl]; return commentsRef; } -(void)viewWillAppear:(BOOL)animated { [[commentsRef child:@"Hello"] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) { NSDictionary * post = snapshot.value; }withCancelBlock:^(NSError * error){ NSLog(@"%@",error.description); }]; } 

告诉我在代码中缺less什么。

  NSString *strUrl = [NSString stringWithFormat:@"https://project-8326407164650950213.firebaseio.com"]; FIRDatabaseReference *ref = [[FIRDatabase database] referenceFromURL:strUrl]; [ref observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) { NSDictionary *post = snapshot.value; NSLog(@"%@",post); }]; 
  • 以下代码将从Firebase获取您的数据。
  • 只有你的代码的问题是你写了“[commentsRef小孩:@”你好“]”。 使用直接的urlreference获取数据。