iphone - Core data: any way to fetch multiple entities? -
i'm getting started core data, , learning exercise i'm building app need display different types of objects in single table view.
as example, have entity "cheese" , unrelated entity "pirate". on main screen of app, user should able create either "cheese" or "pirate" instance add table view.
so, using core data editor i've created entities cheese , pirate... however, nsfetchrequest seems allow retrieve 1 type of entity @ time with:
nsfetchrequest *fetchrequest = [[nsfetchrequest alloc] init]; nsentitydescription *entity = [nsentitydescription entityforname:@"cheese" inmanagedobjectcontext:_context]; [fetchrequest setentity:entity];
is there way perform fetch retrieves "cheese" , "pirate" objects?
thanks.
what you're trying accomplished defining entity inheritance in model, "displayableobject" abstract class defined parent of "cheese" , "pirate".
then can perform fetch request on "displayableobject" entity , retrieve both entities' objects.
take article in apple documentation: https://developer.apple.com/library/ios/documentation/cocoa/conceptual/coredata/keyconcepts.html
Comments
Post a Comment