2010-06-08 74 views

回答

1
NSFetchRequest *request = [[NSFetchRequest alloc] init]; 
NSEntityDescription *entity = [NSEntityDescription entityForName:@"MyEntities" inManagedObjectContext:[self context]]; 
[request setEntity:entity]; 

有设置的要求,呼唤:

NSMutableArray *mutableFetchResults = [[[[self context] executeFetchRequest:request error:&error] mutableCopy] autorelease]; 

会回到我的所有MyEntities的数组persistet由核心数据。

您可以传递请求sortDescriptors或谓词来筛选和排序返回值,但该值始终是一个数组。

这有点棘手,但非常有用。

+0

所以最后,答案是:是的 – dontWatchMyProfile 2010-06-09 09:53:58

+0

是的:)我很少只检索一个实体。它通常是几个,几乎总是按实体上的一个属性排序。 – RickiG 2010-06-10 07:39:36