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
Post a Comment