我尝试从twitter发出特定UIButton
的{{1}}收藏计数。我可以在功能上获得这个数字,我已成功通过Twitter授权。以下是我尝试设置标题的方法:
tweet
当我运行此操作时,我在 //Set number of Favorites for Tweet
NSObject *favoritesCount = [[tweet objectForKey:@"user"]objectForKey:@"favourites_count"];
UIButton *favoritesButton = (UIButton *)[cell viewWithTag:204];
favoritesButton.titleLabel.text = favoritesCount;
以下是我遇到的错误:
favoritesButton.titleLabel.text = favoritesCount;
答案 0 :(得分:2)
标题应为NSString值。您需要将标题设置为NSString而不是NSObject。
NSInteger favoritesCount = [[tweet objectForKey:@"user"]objectForKey:@"favourites_count"];
UIButton *favoritesButton = (UIButton *)[cell viewWithTag:204];
favoritesButton.titleLabel.text = [NSString stringWithFormat:@"%d",favoritesCount];