Я загружаю изображения в специальную папку в Iphone HomeDirectory, но не могу получить к ней доступ, поскольку она сохраняет изображения в случайно сгенерированных именах. Поэтому, пожалуйста, помогите мне, как правильно получить к ним доступ в моей другой функции.
- (void)fetchURL:(NSURL *)url
{
request1 = [ASIHTTPRequest requestWithURL:url];
NSString *str1 = [NSString stringWithFormat:@"savedImage%d",i1];
NSString *path = [self.documentsDirectoryPath stringByAppendingPathComponent:str1];
NSLog(@"saved image path %@",path);
[request1 setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"1.png"]];
//path];
//[request1 setTemporaryFileDownloadPath:[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:@"1"]];
[request1 setAllowResumeForFileDownloads:YES];
[request1 setDelegate:self];
[request1 setDidFinishSelector:@selector(URLFetchWithProgressComplete:)];
[request1 setDidFailSelector:@selector(URLFetchWithProgressFailed:)];
[request1 setDownloadDestinationPath:[[ASIDownloadCache sharedCache] pathToStoreCachedResponseDataForRequest:request1]];
[[ASIDownloadCache sharedCache] setShouldRespectCacheControlHeaders:NO];
[request1 startAsynchronous];
i1++;
//[request1 setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"1.png"]];
//[request setDownloadProgressDelegate:imageProgressIndicator1];
//[self.networkQueue addOperation:request1];
}
Доступ к изображению из другой функции
ASIDownloadCache *cache = [[[ASIDownloadCache alloc] init] autorelease];
//NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES);
self.documentsDirectoryPath = NSHomeDirectory();
//[paths objectAtIndex:0];
[cache setStoragePath:self.documentsDirectoryPath];
NSLog(@"path %@",self.documentsDirectoryPath);
self.destinationPath = [documentsDirectoryPath stringByAppendingFormat:@"/Library/Caches/ASIHTTPRequestCache/SessionStore"];
//NSString *PathStr = [NSString stringWithFormat:@"savedImage%d",i];
//NSString *appFile = [self.destinationPath stringByAppendingPathComponent:PathStr];
//NSString *path = [self.documentsDirectoryPath stringByAppendingPathComponent:PathStr];
//NSLog(@"images path %@",path);
NSLog(@"Download Destination Path %@",[request1 downloadDestinationPath]);
imageView.image = [UIImage imageWithContentsOfFile:[request1 downloadDestinationPath]];
//self.destinationPath];
//[request1 downloadDestinationPath]];
NSLog(@"Image %@ and %d",imageView.image,i);