2017-10-10 40 views
-1

它顯示警告代碼將永遠不會執行。我檢查了3次我的代碼,但不知道如何解決此警告?如何解決此警告目標c中的「代碼將永遠不會執行」?

[[[[self.dbRef child:@"Status"] child:user.uid] child:@"Details"] observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) { 

      //Add Current User Image.....    
     [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me?fields=name,picture.height(100).width(100)" parameters:nil]startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 
      //NSLog(@"Result is : %@",result); 
      NSDictionary *dictionary = (NSDictionary *) result; 
      NSDictionary *data3 = [dictionary objectForKey: @"picture"]; 
      NSDictionary *data2 = [data3 objectForKey: @"data"]; 
      NSString *photoURL = (NSString *)[data2 objectForKey:@"url"]; 
      NSData *imgData = [NSData dataWithContentsOfURL: [NSURL URLWithString: photoURL]]; 
      cell.imgUser.image = [UIImage imageWithData: imgData]; 
      [tableView reloadData]; 
     }]; 


     //Show current user name.... 
     [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me?fields=name,picture.height(100).width(100),name" parameters:nil]startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 

      NSString *currentUName = snapshot.value[@"name"]; 
      NSArray *currentUNameArr = [NSArray arrayWithObject:currentUName]; 
      cell.lblUName.text = currentUNameArr[indexPath.row]; 
      [tableView reloadData]; 
     }]; 

} withCancelBlock:^(NSError * _Nonnull error) { 
    NSLog(@"%@",error.localizedDescription); 
}]; 
+0

您在哪條線上得到該警告? –

+0

第一行.. –

+3

問題出在第一行之前。可能是一個總是正確或錯誤的條件,或者一個「返回」語句。 – Willeke

回答

-1

你錯過了前面的支架,這就是爲什麼它給出了這個警告。嘗試下面的代碼。

[[[[self.dbRef child:@"Status"] child:user.uid] child:@"Details"] observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot * _Nonnull snapshot) { 

    //Add Current User Image..... 
    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me?fields=name,picture.height(100).width(100)" parameters:nil]startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 
     //NSLog(@"Result is : %@",result); 
     NSDictionary *dictionary = (NSDictionary *) result; 
     NSDictionary *data3 = [dictionary objectForKey: @"picture"]; 
     NSDictionary *data2 = [data3 objectForKey: @"data"]; 
     NSString *photoURL = (NSString *)[data2 objectForKey:@"url"]; 
     NSData *imgData = [NSData dataWithContentsOfURL: [NSURL URLWithString: photoURL]]; 
     cell.imgUser.image = [UIImage imageWithData: imgData]; 
     [tableView reloadData]; 
    }]; 


    //Show current user name.... 
    [[[FBSDKGraphRequest alloc] initWithGraphPath:@"me?fields=name,picture.height(100).width(100),name" parameters:nil]startWithCompletionHandler:^(FBSDKGraphRequestConnection *connection, id result, NSError *error) { 

     NSString *currentUName = snapshot.value[@"name"]; 
     NSArray *currentUNameArr = [NSArray arrayWithObject:currentUName]; 
     cell.lblUName.text = currentUNameArr[indexPath.row]; 
     [tableView reloadData]; 
    }]; 

} withCancelBlock:^(NSError * _Nonnull error) { 
    NSLog(@"%@",error.localizedDescription); 
}]; 
+0

與問題中的代碼有什麼不同?爲什麼? – Willeke

+0

在前面增加了一個支架。否則該塊不會完整。問題中的代碼看起來像是在飛行中。 –

+0

現在我在我的答案中添加了描述@Willeke –

相關問題