Note that there are some explanatory texts on larger screens.

plurals
  1. POExecuteFetchRequest returns null values
    primarykey
    data
    text
    <p>hi my code for inserting data is as follows ( It receives json data from a server , parses it and inserts it) </p> <pre><code>- (void)connectionDidFinishLoading:(NSURLConnection *)connection { [myButton setTitle:@"Get o/p from file" forState:UIControlStateNormal]; JsonStorage *event = (JsonStorage *)[NSEntityDescription insertNewObjectForEntityForName:@"JsonStorage" inManagedObjectContext:managedObjectContext]; NSDictionary *json=[NSJSONSerialization JSONObjectWithData:mutabledata options:NSJSONReadingMutableContainers error:nil]; NSDictionary *message=[json objectForKey:@"message"]; NSMutableString *stringtemp=[[NSMutableString alloc] init]; //[temp appendString:@"Message: \n"]; for(id key in message) { [stringtemp appendString:[[NSString alloc] initWithFormat:@"%@ is %@ \n",key,message[key]]]; } [event setMessage1:[[NSString alloc] initWithString:stringtemp]]; [event setApplicationid:[[NSString alloc] initWithFormat:@"application id is %@",json[@"applicationid"]]]; [event setRankings:[[NSString alloc] initWithFormat:@"Rankings for %@",json[@"rankings"]]]; NSArray *array=[json objectForKey:@"ranks"]; NSMutableString *temp=[[NSMutableString alloc] init]; for(int i=0;i&lt;[array count];i++) { NSDictionary *rank=array[i]; [temp appendString:[[NSString alloc] initWithFormat: @"username is %@\n",rank[@"user_name"]] ]; [temp appendString:[[NSString alloc] initWithFormat: @"email id is %@\n",rank[@"user_email"]] ]; int inc=i+1; [temp appendString:[[NSString alloc] initWithFormat: @"%@",rank[[[NSString alloc] initWithFormat:@"%d",inc ]]] ]; [temp appendString:[[NSString alloc] initWithFormat: @"\n"]]; } [event setRankdetails:temp]; NSLog(@"asdasfafew %@",[event rankdetails]); NSError *error; if (![managedObjectContext save:&amp;error]) { // This is a serious error saying the record could not be saved. // Advise the user to restart the application NSLog(@"error"); } [eventArray insertObject:event atIndex:0]; secondlabel.text=[NSString stringWithFormat:@" Date received, It is stored in the core data\n " ]; } </code></pre> <p>values are getting inserted properly, then my refreshview function ( which fetches data from the core data) is as follows</p> <pre><code> - (void) RefreshView { NSEntityDescription *entity = [NSEntityDescription entityForName:@"JsonStorage" inManagedObjectContext:managedObjectContext]; // Setup the fetch request NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:entity]; // Fetch the records and handle an error NSError *error; NSMutableArray *mutableFetchResults; [mutableFetchResults removeAllObjects]; mutableFetchResults= [[managedObjectContext executeFetchRequest:request error:&amp;error] mutableCopy]; if (!mutableFetchResults) { NSLog(@"too big error"); // Handle the error. // This is a serious error and should advise the user to restart the application } // Save our fetched data to an array [self setEventArray: mutableFetchResults]; NSMutableString *temp2=[[NSMutableString alloc] init]; //temp2=nil; for (NSManagedObject *info in eventArray) { // NSLog(@"reached refreshview"); NSString *temp=[[NSString alloc] initWithFormat:@"%@",[info valueForKey:@"message1"]]; //NSLog(@"Value is %@",temp); [temp2 appendString:temp]; // [temp2 appendString:@"\n"]; //NSLog(@"reached refreshview1"); NSString *temp3=[[NSString alloc] initWithFormat:@"%@",[info valueForKey:@"applicationid"]]; [temp2 appendString:temp3]; // [temp2 appendString:@"\n"]; //NSLog(@"reached refreshview2"); NSString *temp4=[[NSString alloc] initWithFormat:@"%@",[info valueForKey:@"rankings"]]; [temp2 appendString:temp4]; // [temp2 appendString:@"\n"]; //NSLog(@"reached refreshview3"); NSString *temp5=[[NSString alloc] initWithFormat:@"%@",[info valueForKey:@"rankdetails"]]; [temp2 appendString:temp5]; } //NSLog(@"final temp is %@",temp2); NSString *finalstring=[temp2 stringByReplacingOccurrencesOfString:@"(null)" withString:@""]; //NSLog(@"final string is is %@",finalstring); secondlabel.text=finalstring; } </code></pre> <p>temp2 keeps printing (null)(null).... Thanks in advance</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload