samedi 4 avril 2015

FMDB - Simulator faster than real device [Insert]

I have about 2,300 records to insert. When I use this code in Simulator its very fast but when I used it in real device (iPhone 6 Plus, iOS 8) its very very slow I do not know where is the problem exactly so if you have any related topic or a hint to improve this perfomance.


this my code



NSURL *URL = [[NSURL alloc] initWithString:@"http://ift.tt/1EZg8IM"];
NSString *xmlString = [[NSString alloc] initWithContentsOfURL:URL encoding:NSUTF8StringEncoding error:NULL];
NSDictionary *xmlDoc = [NSDictionary dictionaryWithXMLString:xmlString];
NSArray *thetable = [xmlDoc arrayValueForKeyPath:@"Table"];
for (int i = 0;i<thetable.count;i++) {
NSString *insert = [NSString stringWithFormat:@"insert into times(date,id,key,mtime,place_id,price) values(\"%@\",\"%@\",\"%@\",\"%@\",\"%@\",\"%@\")",[[[thetable objectAtIndex:i] valueForKey:@"date"] substringToIndex:10],[[thetable objectAtIndex:i] valueForKey:@"id"],[[thetable objectAtIndex:i] valueForKey:@"key"],[[thetable objectAtIndex:i] valueForKey:@"mtime"],[[thetable objectAtIndex:i] valueForKey:@"place_id"],[[thetable objectAtIndex:i] valueForKey:@"price"]];
[db executeUpdate:insert];
}


Thanks in advance


Aucun commentaire:

Enregistrer un commentaire