I am parsing data using ASIHTTPRequest
. Now, I want to store that
data in core data. Used this
API.
My Entity Name SMS and includes three atrributes Id,Name and IsActive.
This code to parse data.
-(void)DataRetireve
{
deatilinfoarray = [[NSMutableArray alloc] init];
NSURL *url = [NSURL URLWithString:
@"http://sms.instatalkcommunications.com/apireq/GetSMSCategories?
t=1&h=admin¶m=1"];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];``
[request setDelegate:self];
[request startAsynchronous];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSError *error;
NSString *responseString = nil;
if (!error)
{
responseString = [request responseString];
SBJsonParser *parser = [[SBJsonParser alloc] init] ;
NSMutableArray *jsondata = [parser objectWithString:responseString];
NSMutableArray *jsondata1 = [[NSMutableArray alloc]init];
info *myinfo=[[info alloc]init];
for(int i=0;i<jsondata.count;i++)
{
myinfo.Id=@"Id";
myinfo.Name=@"Name";
myinfo.IsActive=@"IsActive";
[jsondata1 addObject:myinfo];
NSLog(@"%@",responseString);
}
for(int i=0;i<jsondata1.count;i++)
{
myinfo= [jsondata1 objectAtIndex:i];
NSManagedObjectContext *context=[self managedObjectContext];
NSManagedObject *sms = [NSEntityDescription insertNewObjectForEntityForName:@"SMS" inManagedObjectContext:context];
NSLog(@"%@", context);
[sms setValue:@"Id" forKey:@"Id"];
[sms setValue:@"Name" forKey:@"Name"];
[sms setValue:@"IsActive" forKey:@"IsActive"];
[jsondata1 addObject:myinfo];
}
Done code for that but give me error