我正在尝试以这种方式从 Dropbox 下载一些图像:
-(void)catchTheImage{
NSString *title = [[NSUserDefaults standardUserDefaults]objectForKey:@"Folder3"];
PhotoViewController* sharedSingleton = [PhotoViewController sharedManager];
NSString *filename2 = [NSString stringWithFormat:@"/%@photofile.png.%ld", title, (long)sharedSingleton.tagNumber];
NSString *tmpPngFile = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", filename2]];
[restClient loadFile:filename2 intoPath:tmpPngFile];
[NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(lf) userInfo:nil repeats:NO];
}
-(void)lf{
NSString *tmpPngFile = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", filename2]];
UIImage* image = [UIImage imageWithContentsOfFile:tmpPngFile];
photoView.image = image;
}
我知道计时器不是一个好主意,但它只是为了尝试。TagNumber 可以是 1、2 或 3,因为 Dropbox 上的图像是 3,但图像没有显示出来。我认为它们根本没有保存在文件夹中。可能是我对 NSTemporaryDirectory 的工作方式有误解......