iOS - getting data in wrong order from CoreData
This is how i am inserting the data,
NSEntityDescription * entityDescription = [NSEntityDescription
entityForName:[DOSnow entityDescription] inManagedObjectContext:
proxy.managedObjectContext];
DOCurrentCondition *doSnow = [[[DOSnow alloc]
initWithEntity:entityDescription insertIntoManagedObjectContext:
proxy.managedObjectContext] autorelease];
NSXMLElement *snowConditionsElement = [[roseElement elementsForName:SNOW]
lastObject];
NSArray *snowElements = [snowConditionsElement children];
for (NSXMLElement *snowElement in snowElements)
{
NSEntityDescription * entityDescription = [NSEntityDescription
entityForName:[DOPair entityDescription] inManagedObjectContext:
proxy.managedObjectContext];
DOPair *pair = [[[DOPair alloc] initWithEntity:entityDescription
insertIntoManagedObjectContext: proxy.managedObjectContext]
autorelease];
pair.key = [snowElement name];
pair.value = [snowElement stringValue];
[doSnow addConditionsObject: pair];
}
[proxy save];
And this is how i am fetching the data,
- (NSArray *) fetchSnowConditions
{
ApplicationFacade *appFacade = [ApplicationFacade appFacade];
NSManagedObjectContext *context = appFacade.rProxy.managedObjectContext;
NSFetchRequest * request = [[[NSFetchRequest alloc] init] autorelease];
[request setEntity:[NSEntityDescription entityForName:[DOSnow
entityDescription] inManagedObjectContext:context]];
NSError *error;
NSArray *result = [context executeFetchRequest:request error:&error];
return result;
}
So i am not getting the data in same order as i inserted.
No comments:
Post a Comment