ios - The world of generated NSManagedObjects and a Superclass -


i have several generated nsmanagedobject subclasses. using article created parent class (named qualifier) nsmanagedobject subclasses extend. in way can have class hierarchy without entity hierarchy.

i have problem won't know until runtime subclass need create. have string representing class name. put method in qualifier class creates specific subclass:

+ (instancetype) insertnewobjectfor:(nsstring *) qualifiername intocontext:(nsmanagedobjectcontext *) managedobjectcontext {      nsmanagedobjectmodel *managedobjectmodel = [[managedobjectcontext persistentstorecoordinator] managedobjectmodel];     class qualifierclass = nsclassfromstring(qualifiername);     nsentitydescription *entity = [[managedobjectmodel entitiesbyname] objectforkey:qualifiername];     qualifier *object = [[qualifierclass alloc] initwithentity:entity insertintomanagedobjectcontext:managedobjectcontext];      return(object);  } 

i'm new @ objective c , wanted ask more informed stack exchangers if acceptable way create specific instance?

that's fine, although it's more steps necessary. i'd simplify to:

qualifier *object = [nsentitydescription insertnewobjectforentityforname:qualifiername      inmanagedobjectcontext:context]; 

Comments

Popular posts from this blog

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -