Since I'm downloading images to show in runtime, I'm getting the application main bundle path with this code below:
NSString *path = [NSString stringWithFormat:@"%@", [[NSBundle mainBundle] executablePath]];
NSArray *parts = [path componentsSeparatedByString:@"/"];
NSString *pathToSave = [path substringToIndex:([path length] - [[NSString stringWithFormat:@"%@", [parts objectAtIndex:[parts count]-1]] length])];
And I save images with this code:
NSString *url = [NSString stringWithFormat:@"%@", [imageURLs objectAtIndex:0]];
NSString *filename = [url lastPathComponent];
NSData *thedata = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]];
NSString *localFilePath = [NSString stringWithFormat:@"%@%i%@", pathToSave, [[NSString stringWithFormat:@"%@", [element child:@"id"]] intValue], filename];
[thedata writeToFile:localFilePath atomically:YES];
When I manually download an image and add to project, [UIImageView setImage:]
did work this time. So I realized that there's something wrong with saving images from URL.
The reason I didn't think this should be the problem is that it's working just fine with the iOS simulator.
I'll take a look at that issue, however since my application name contains special characters like "İ" (Turkish) I think that might be the reason, the application might not be able to save to correct path.