【发布时间】:2010-11-23 08:55:17
【问题描述】:
我尝试用核心数据发出一种“sql distinct”请求, 所以我像这样设置我的 NSFetchrequest
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
[fetchRequest setEntity:[NSEntityDescription entityForName:@"my_table" inManagedObjectContext:managedObjectContext]];
[fetchRequest setResultType:NSDictionaryResultType];
[fetchRequest setReturnsDistinctResults:YES];
[fetchRequest setPropertiesToFetch:[NSArray arrayWithObjects:@"first_property",@"second_property",nil]];
// Execute the fetch
NSError *error;
table_dom = [[NSArray alloc] init];
table_dom = [managedObjectContext executeFetchRequest:fetchRequest error:&error];
[fetchRequest release];
这对我来说看起来不错,但我想我用 NSDictionary 检索一个 NSArray 填充,是这样吗?
所以我的问题是如何从 table_dom 中提取数据用于 tableview,我尝试了很多东西但没有一个有效?
它必须是: cell.textLabel.text = //“第一个属性”和 cell.detailTextLabel.text = //"second_property"
或者为了简单起见,我可以使用 setReturnsDistinctResults 而不是 NSDictionary 检索对象吗?
谢谢
【问题讨论】:
标签: iphone objective-c core-data