0
私はFirebaseで次のデータベース、私はデータを取得し、uitableのビューでそれらを表示しようとしています はObjective Cの中でuitableの中firebaseデータベースやショーからデータを取得
を持っています。まず、データベースから契約書を取りたいと思います。今のところ合意の記録は1つだけですが、将来は多くの記録が残るでしょう。私は以下のコードを試しました
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
//self.clearsSelectionOnViewWillAppear = NO;
[[_firebaseDatabaseRef child:@"krib-60229"] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *_Nonnull snapshot){
self.allSnapshot = [NSMutableArray array];
NSLog(@"%@",self.allSnapshot);
NSLog(@"%s","TestTestTest");
for(snapshot in snapshot.children){
[self.allSnapshot addObject:snapshot];
}
[self.tableView reloadData];
}];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.allSnapshot count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
FIRDataSnapshot *snapShot = [self.allSnapshot objectAtIndex:indexPath.row];
NSString *testText = snapShot.value[@"landlordDisplayName"];
cell.textLabel.text = testText;
// Configure the cell...
return cell;
}
私は何も取得しなかったり、何かエラーが発生しません。私はNSLogを置こうとしましたが、印刷していません。私はObjective CでIOSを開発するのが初めてです。どんな助力も感謝します。