即時解析一個JSON文件。邏輯是這樣的,如果沒有數據名爲boy.it的變量需要進入if循環,並且如果有數據進入else部分。但問題是,即使變量男孩是空的(這表明在控制檯空)環路仍然進入別人part..cud u人幫我out..below是代碼..if語句的問題
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
NSDictionary *boy=[url objectAtIndex:indexPath.row];
NSLog(@"the boy value:%@",boy);
if (boy == NULL)
{
Secondetailview *detailViewController1 = [[Secondetailview alloc] initWithItem:boy];
[self.navigationController pushViewController:detailViewController1 animated:YES];
[detailViewController1 release];
}else
{
FirstViewDetail *detailViewController = [[FirstViewDetail alloc] initWithItem:boy];
[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];
}
}
mkay ......我試着用nil..still無法進入,如果環...做ü沒有的詞典中的任何符號 – kingston
那是絕對一樣的 – hamstergene
-1不正確。 'nil' =='NULL' =='0'(大致在最後一個),因爲Objective-C只是掛在C/C++上。然而,在Objective-C中使用'nil'確實是更正確的:-) – 2011-08-18 05:24:45