mardi 10 février 2015

How to insert imagedata into sqlite asyncronously in ios

I'm inserting imagedata into sqlite using these lines



imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:
[dict objectForKey:@"image_url"]]];
sqlite3_bind_blob(stmt, 5, [imageData bytes], [imageData length],NULL);


it is working fine but in that image_url I had 50 images ,it makes my app opens slow,so i decided to insert them asyncronously for that I used this code below but images are not inserting in sqlite databse.



dispatch_async(dispatch_get_main_queue(), ^
{
imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:
[dict objectForKey:@"image_url"]]];
sqlite3_bind_blob(stmt, 5, [imageData bytes], [imageData length], NULL);
});


Now what i need is isthere any other way to insert, which makes my app to open fastly? Thanku


Aucun commentaire:

Enregistrer un commentaire