ios - Core Data error message -


i created core data entity named: "athlete".

here error getting:

terminating app due uncaught exception 'nsinvalidargumentexception', reason: '+entityforname: nil not legal nsmanagedobjectcontext parameter searching entity name 'athlete'' 

this line @ breaks:

athlete *detail = [nsentitydescription insertnewobjectforentityforname:@"athlete" inmanagedobjectcontext:context]; 

delegate.h

@property (readonly, strong, nonatomic) nsmanagedobjectcontext *managedobjectcontext; @property (readonly, strong, nonatomic) nsmanagedobjectmodel *managedobjectmodel; @property (readonly, strong, nonatomic) nspersistentstorecoordinator *persistentstorecoordinator; 

delegate.m

-(void)createdata{      nsmanagedobjectcontext *context = [self managedobjectcontext];      athlete *detail = [nsentitydescription insertnewobjectforentityforname:@"athlete" inmanagedobjectcontext:context];      detail.first = @"joe";      detail.last = @"pastrami";      detail.phone = @"(123)456-7891";      nserror *error;      if(![context save:&error]){         nslog(@"error :(");     }      nsfetchrequest *request = [[nsfetchrequest alloc] init];      nsentitydescription *entity = [nsentitydescription entityforname:@"athlete" inmanagedobjectcontext:context];      [request setentity:entity];      nsarray *arr = [context executefetchrequest:request error:&error];      (athlete *ath in arr){         nslog(@"name %@", ath.first);     }  }    - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     [self createdata]; } 

the error says all: managedobjectcontext nil.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -