我如何打印实体的内容,例如客户?

我希望数据像表一样,例如实体数据应如此打印:

名字|姓氏|电话号码|电子邮件| DOB

我还需要在打印数据之前应用搜索谓词,例如1984年以后出生的印刷会员

有人能告诉我应该怎么做吗?

谢谢!

有帮助吗?

解决方案

我发现此链接帮助我使用核心数据: http://iphoneinaction.manning。 COM / iphone_in_action / 2009/09 /芯 - 数据 - 部分-3-检索-data.html

将实体强制转换为数组,循环数组并为每个结果NSLog数据。 E.g:

NSEntityDescription *entity = [NSEntityDescription entityForName:@"news" 
                                          inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"url=%@",theUrl];
[fetchRequest setPredicate:predicate];

NSError *error;
NSArray *items = [self.managedObjectContext
                   executeFetchRequest:fetchRequest error:&error];

for (news *theNews in items) {
    NSLog(@"Title: %@, Date: %@, News: %@", [theNews title], [theNews date], [theNews news]);
}

[fetchRequest release];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top