Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
I wrote a Mac program that I can select a local image, resized it and pass to a PHP file to save to my server, which works fine. The other part of the program loads the file from the server back in to the program which I have the problem with.

I have 6 images named "photo0.jpg", "photo1.jpg" and so on. So if a photo exists it over writes it in the PHP code, which it does, and I varified that. But in my objective C code it is loading the old image file still?

Code:
    int photoNum = [photos intValue]; // gets the count for the num of photos.
    for (int i = 0; i <  photoNum; i++) {
        NSString *photoImagePath = [NSString stringWithFormat:@"%@%@",folderPath,[fileNameArray objectAtIndex:i]];
        NSImage *photoImage = [[NSImage alloc]initWithContentsOfURL:[NSURL URLWithString:photoImagePath]];
        NSImageView *photoView = [photoObjectArray objectAtIndex:i];
        photoView.image = photoImage;

    }

When I check the paths manually using FireFox it show the correct image, or the new one that was replaced. But when I load it from with in my program the correct path displays the old image that should have been overwritten?

I even stop the app, quit out of xcode, re launch and reload the images and the same thing? The program works without error, it is just retrieving the file that should have been over written. Is something buffered that needs cleaning out?

Any ideas?
 

larswik

macrumors 68000
Original poster
Sep 8, 2006
1,552
11
After about 20 hours of debugging the problem was with with GCD. Background threads are tricky if you are expecting it to return data by the time the main thread needs it.

It was difficult to go line by line when you have a number of threads happening at the same time.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.