Tuesday 15 June 2010

ios - NSManagedObject save only the latest object and not the whole objects -


I have a Jason response, I am trying to save the original data using the NSMNase object with the following code :

  - (zero) breakTrapsToSave: (NSDictionary *) trapsDict {tempA = [trapsDict objectForKey: @ "envelope"]; TempB = [tempA objectForKey: @ "body"]; TempC = [tempB ObjectForchy: @ "Gettreps Response"]; TempD = [tempC objectForKey: @ "getTrapsResult"]; TempE = [tempD objectForKey: @ "trap"]; Self.lastUpdate = [tempE objectForKey: @ "last exception"]; [Self. Chevrooper set object: self. Update for unknown: @ "last_update"]; [Self. Synchrite Synopsis]; NSLog (@ "net newest update:% @", auto update .last); TempF = [tempE ObjectForchy: @ "TRAP"]; [Tempf enumerate Objektusinging lock: ^ (ID Ojj, Ansuintejr Aidiaks, Ball * Stop) {TempA = [Temff Objektatindaks: Aidiaks]; NSString * Final result; NSString * key; For (int i = 0; i & lt; node.count; i ++) {tempB = [tempA object foreci: [node object atx: x]]; FinalResult = (NSString *) tempB; Key = [node object atxaxx]; [Auto addToCoreData_value: last result key: key]; // core data} counter = idx; }]; NSLog (@ "Total Network:% d", Counter); } #pragma Icon - Core Data Paths - (zero) initCoreData {IDANAppDelegate * appDelegate = [[UIApplication shared application] representative]; Context = appDelegate.managedObjectContext; EntityDesc = [NSEntityDescription EntityForName: @ Managed Object Contains in "Trap": Reference]; ManagedObject = [[NSMANGE Object Alok] Init With Identity: Antidys Dot In Managed Object Contains: Reference]; } - (void) addToCoreData_value: (NSString *) Value Key: (NSString *) key {if ([key isEqualToString: @ "alarmDistance"]] [key isEqualToString: @ "degree"] || [key isEqualToString: @ "ID []] to [[key isEqualToString: @ "polys"] [[key isEqualToString: @ "roadNumber"]] [key isEqualToString: @ "type"]) {[managedObject setValue: [Ansanmber Snkyaadhari: [value IntValue]] Key: Key];} else if ([key Akseltostring: @ "late"]] [key Akseltostring: @ "lawn"]) [[managed object set value: [Ansanmber number with Flotः [value float value] Ltd. Key: Key];} else if ([key Akseltostring: @ "active"]) {BOOL cosette = false; if ([ValueEqualToString: @ "true"]) {toSet = YES;} and {toSet = NO;} [ managed object set value: [Ansanmber number Vithbuls: Tuset] of the key];} and {{managedObject setValue: value: key];} NSError * error [Save reference: & amp; error];} < This is, I logged in and I saw that I get the right value and keys through the entire  enumerateObjectsUsingBlock  loop. In addition, in:  
  - (zero) addToCoreData_value: (NSString *) value key: (NSString *) key   

I did a log and I I see all the keys and value. But when I open the squalight, then I see only one row in the table, the last thing. NSLog (@ "Total Network:% d", Counter); - The right amount of items also print (116 for now).

What am I doing wrong?

It seems that you only have a managed object that you are doing it sequentially Changing the qualities.

What you should do is create new managed objects to save each item.

No comments:

Post a Comment