Reputation: 592
After searching the internet for weeks & a lot of posts here in stack too, i can't seem to find the way to implement this in my project.
I have a plist in my dropbox account. one of the strings in the plist under one of the dictionaries called "cellPic".
I want to display the pics of the stores that i have in my dropbox, on the table cells.
The plist is downloaded to my docs path:
-(void)readPlistFromServerAndSaveToDocs
{
//save plist from server to docs:
NSArray *tempArr1 = [[NSArray alloc]initWithContentsOfURL:
[NSURL URLWithString:@"http://dl.dropbox.com/u/4082823/AppsFiles/Black/stores.plist"]];
NSString *error;
NSString *rootPath =
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];
NSString *plistPath = [rootPath stringByAppendingPathComponent:@"stores.plist"];
NSArray *tmpArr = [NSArray arrayWithArray:tempArr1];
NSData *tmpData = [NSPropertyListSerialization dataFromPropertyList:tmpArr
format:NSPropertyListXMLFormat_v1_0 errorDescription:&error];
NSLog(@"plistPath=%@",plistPath);
if(tmpData)
{
[tmpData writeToFile:plistPath atomically:YES];
}
else
{
NSLog(@"%@",error);
}
//Announcement if there is no server connection:
if(tempArr1.count == 0)
{
[self plistMessages];
}
}
So far everything ok...
In my TableViewController under this method i want to implement the asynchronously images loading for the cells.
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
My goal is to read/download asynchronously the images but i don't know how it goes - do i need to read the strings in my plist on my docs path that contains the full url address of the pic or i need to download the pics from the server to my docs & then read it to the cell?
In my case - the cells possitions are changing cau's they are sorted by the user location (nearest store to the user is on top of the table) that why i think that i need to read it from my plist.
This is one of my pics url: http://dl.dropbox.com/u/4082823/AppsFiles/Black/ramat-hasharon.png
What is the best way to do that & how can i downloading all the png images at once (if needed)?
I've tried to do it with this tutorial but it didn't went at all.
http://www.switchonthecode.com/tutorials/loading-images-asynchronously-on-iphone-using-nsinvocationoperation
Help will be appriciated!!
Thanks!
Upvotes: 1
Views: 898