1

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!

Maor Zohar
  • 592
  • 5
  • 17

1 Answers1

2

Take a look at Apple's sample code LazyTableImages.

Rok Jarc
  • 18,765
  • 9
  • 69
  • 124
lawicko
  • 7,246
  • 3
  • 37
  • 49
  • Thanks lawicko, i looked at it earlier but it looks like there is a lot of code & subclasses to implement. i'm sure there is a short way to do that from the codes i saw on the net but i'm all confused & don't know how to do that :/ – Maor Zohar Feb 27 '12 at 17:38
  • 1
    Seriously? There are only two classes there that should be of interest to you, `IconDownloader` and `RootViewController`. I'm buying a beer if you find easier example than this. – lawicko Feb 27 '12 at 18:02
  • :) ohh i thaught i needed all of them! sorry.. i'll try to make it work with this example.. sorry, i'm new with xcode... if it's working - i'll buy you a beer ;) – Maor Zohar Feb 27 '12 at 18:07
  • +1 for a great link. Formatted your answer a bit - hope you don't mind. – Rok Jarc Mar 21 '12 at 10:34
  • @AlexisW Since this doesn't have anything to do with this question, you should create a new question and precisely describe the problem that you are experiencing, especially paste all the errors that you see and as much code as possible. – lawicko Jun 06 '12 at 20:17