首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Core-Data:打印实体的内容

Core-Data:打印实体的内容
EN

Stack Overflow用户
提问于 2009-11-27 00:57:56
回答 1查看 1.9K关注 0票数 1

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

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

名字|姓氏|电话|邮箱|道布

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

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

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-11-28 00:05:10

我找到了这个链接,它帮助我使用了很多核心数据:http://iphoneinaction.manning.com/iphone_in_action/2009/09/core-data-part-3-retrieving-data.html

将实体转换为数组,循环数组,并为每个结果NSLog数据。例如:

代码语言:javascript
复制
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];
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1804773

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档