NSString *urlstring;
NSURL *url;
NSError *err = nil;
NSURL *path;
//serverIp1 サーバーのURL (http://xxxx.jp/xxxx/)
//dirPath 保存先のURL
//imageFile 画像ファイル名
//textFile テキストファイル名
//Download ImageFile
urlstring = [serverIp1 stringByAppendingString:imageFile];
url = [NSURL URLWithString:urlstring];
NSData *data = [NSData dataWithContentsOfURL:url options:nil error:&err];
//Write
path = [dirPath URLByAppendingPathComponent:ImageFile];
BOOL result = [data writeToURL:path options:NSDataWritingAtomic error:&err];
if (result == NO) break;
//Download Text file
urlstring = [serverIp1 stringByAppendingString:textFile];
url = [NSURL URLWithString:urlstring];
NSString *str = [NSString stringWithContentsOfURL:url encoding:NSShiftJISStringEncoding error:&err];
//Write
path = [dirPath URLByAppendingPathComponent:textFile];
result = [str writeToURL:path atomically:YES encoding:NSUTF8StringEncoding error:&err];
if (result == NO) break;
0 件のコメント:
コメントを投稿