このコードはシミュレーターで問題なく動作し、ファイルを書き出します。
ただし、iPhone では、ファイルは書き出されません。
DLog(@"");
timeStart = [NSDate date];
NSURL *url = [NSURL URLWithString:SAT_URL];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:FILE_NAME];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:NO];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
DLog(@"updated words to: %@",path);
//DLog(@"response: %@",responseObject);
[self processWords];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
// Deal with failure
}];
[operation start];
rawWords と行はすべてデバイス上で null です:
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:FILE_NAME];
NSString *rawWords = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSArray *lines = [rawWords componentsSeparatedByString:@"\n"];
これは AFNetworking ライブラリを使用しており、さまざまなホスティング事業者からファイルを取得しようとしました。
私は何を間違っていますか?