Strange URL load problem

Discussion in 'Mac Programming' started by larswik, May 8, 2013.

  1. larswik macrumors 68000

    Sep 8, 2006
    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?

        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?
  2. larswik thread starter macrumors 68000

    Sep 8, 2006
    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.

Share This Page