for (NSDictionary *firstDictionaryTemp in alertArray) {
if ([firstDictionaryTemp objectForKey:@"user_name"]) {
uId = [firstDictionaryTemp objectForKey:@"u_id"];
catId = [firstDictionaryTemp objectForKey:@"cat_id"];
myDictionary = [firstDictionaryTemp objectForKey:@"topic_detail"];
for (NSDictionary *secDictionaryTemp in myDictionary) {
if ([secDictionaryTemp objectForKey:@"description"]) {
dictionaryDescription = [secDictionaryTemp objectForKey:@"description"];
[result1 addObject : dictionaryDescription];
}
}
}
...
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return result1.count;
// return [result1 count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath : indexPath];
UILabel *name2 = (UILabel *)[cell viewWithTag:30];
name2.text = [result1 objectAtIndex : indexPath.row];
return cell;
}
{
JSON "主题":[ { " topic_id":" 66", " cat_id":" 74", " topic_title":" ssss", " userid":" 70", " total_views":" 1", " user_name":" abc", " topic_detail":[ { "描述":" Re", " total_reply":0 } ] " is_bookmark":" false" }, { " topic_id":" 43", " cat_id":" 74", " topic_title":" ee", " userid":" 70", " total_views":" 1", " user_name":" abc", " topic_detail":[ { "描述":" Ee", " total_reply":0 } ] " is_bookmark":" false" }, { " topic_id":" 40", " cat_id":" 74", " topic_title":" demo2", " userid":" 66", " total_views":" 1", " user_name":" 1", " topic_detail":[ { "说明":" demo2", " total_reply":0 } ] " is_bookmark":" false" }, { " topic_id":" 39", " cat_id":" 74", " topic_title":" demo", " userid":" 66", " total_views":" 1", " user_name":" 1", " topic_detail":[ { "说明":"演示", " total_reply":0 } ] " is_bookmark":" false" } ] }
答案 0 :(得分:0)
if alertArray.count > 0
{
// execute your code
}
else
{
// empty array
}
检查数组是否为空是很简单的。希望这会对你有所帮助。
答案 1 :(得分:-1)
如果你正在进入其他部分。那么你在做什么呢?分享代码
if alertArray.count > 0
{
// execute your code
}
else
{
// empty array
}