我正在尝试在我的 iPad 上编译应用程序。我正在使用 AFNetworking 来获取我的 FTP 上的文件列表。应用程序在模拟器上运行,但是当我在 iPad 上启动它时,我得到(空)文件内容和列表。这是代码:
- (void) getListOfFiles {
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"ftp://anonymous@ftphost/"]];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
NSString *path = [[[NSBundle mainBundle]resourcePath]stringByAppendingPathComponent:@"list"];
operation.outputStream = [NSOutputStream outputStreamToFileAtPath:path append:YES];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, NSHTTPURLResponse *response) {
NSLog(@"Success %@",operation.response);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", [error localizedDescription]);
}];
[operation start];
NSString *content = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
NSLog (@"%@",content);
}
所以 variable content = (null) 只在 iPad 上,在 Simulator 上一切都很好。请帮忙,我已经失去了任何希望)