2012-02-12 14 views
-1

JSON的,我怎麼能 「的NSLog」 只有標題在此代碼:如何NSLog從NSDictionary對象的字符串?

NSDictionary *item = [tableData objectAtIndex:[indexPath row]]; 
    // Set text on textLabel 
    [[cell textLabel] setText:[item objectForKey:@"title"]]; 
    // Set text on detailTextLabel 
    [[cell detailTextLabel] setText:[item objectForKey:@"description"]]; 

喜歡的東西NSlog(@"%@", title);

謝謝!

回答

1

如果我明白你的要求正確,那麼這應該這樣做:

NSLog(@"%@", [item objectForKey:@"title"]); 

如果給你一個編譯器警告,因爲對象可能不是一個NSString,那麼你可以做:

NSString *title = [item objectForKey:@"title"]; 
NSLog(@"%@", title); 

如果我誤解了你的問題,請讓我知道,我會相應地更正我的答案。

相關問題