Objective-c writeToFile 不适用于 iPad,适用于模拟器
我已经看到 writeToFile 不适用于非对象的解释, 然而,这段代码显示 iPad 设备上的功能存在严重差距 以及模拟器如何工作。
NSMutableArray *arrayOne = [NSMutableArray arrayWithObjects:@"Thing One", @"Thing Two", @"Thing Three", nil];
[arrayOne writeToFile:@"myLocalMovieMetaData-v11" atomically:YES];
NSLog(@"cancelNowButton Test Metadata File Written.");
NSMutableArray *arrayTwo = [NSMutableArray arrayWithContentsOfFile:@"myLocalMovieMetaData-v11"];
NSLog(@"arrayOne: %@",arrayOne);
NSLog(@"arrayTwo: %@",arrayTwo); //this prints on simulator but not the device.
I've seen the explanation that writeToFile doesn't work with non-objects,
however, this snippet shows there is a serious gap in what works on the iPad device
and how the simulator works.
NSMutableArray *arrayOne = [NSMutableArray arrayWithObjects:@"Thing One", @"Thing Two", @"Thing Three", nil];
[arrayOne writeToFile:@"myLocalMovieMetaData-v11" atomically:YES];
NSLog(@"cancelNowButton Test Metadata File Written.");
NSMutableArray *arrayTwo = [NSMutableArray arrayWithContentsOfFile:@"myLocalMovieMetaData-v11"];
NSLog(@"arrayOne: %@",arrayOne);
NSLog(@"arrayTwo: %@",arrayTwo); //this prints on simulator but not the device.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
应用程序只有写入其 Documents 目录的权限:
然后使用:
The application only has permission to write to its Documents directory:
Then use: