下面是我的代码,假设我想从网上获取图像并将其保存在我的设备中,但出现我无法解决的错误,请帮助。
for ( int i=1; i<=numberOfSlides; i++) {
NSString *picURLstring = [NSString stringWithFormat:@"http://example.com/Slide%d.jpg", i] ;
NSURL *picURL = [NSURL URLWithString:picURLstring] ;
UIImage *Slide = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:picURL]];
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES);
NSString *docPostion = [path objectAtIndex:0] ;
docPostion = [docPostion stringByAppendingPathComponent:@"Slide%d.png",i];
}
错误发生在以下行:
docPostion = [docPostion stringByAppendingPathComponent:@"Slide%d.png",i];
我想根据变量i将图像保存到名称中,我保证这段代码在C语言中是正确的,但是现在在objective-c中我不知道为什么我不能这样做。