小编zak*_*ton的帖子

从XCode Bundle读取文本文件

为什么我不能读取foo.rtf的内容?我已经把它放在XCode包中了.fileRoot仍然包含null.

NSString* filePath = @"foo";
NSString* fileRoot = [[NSBundle mainBundle] pathForResource:filePath ofType:@"rtf"];       

NSLog(@"File root contains %@", fileRoot);
Run Code Online (Sandbox Code Playgroud)

感谢任何人对此的帮助.


@TheAmateurProgrammer,谢谢你的图表.我刚刚将foo.rtf添加到了bundle资源中.fileRoot的结果仍为null.我还缺什么步骤?

Build Phases中Target的"Copy Bundle Resources"现在包含foo.rtf.(我不能插入图片,因为我还是新手).

(我可以在fileRoot指向正确后添加内容读取).

macos xcode bundle file objective-c

4
推荐指数
1
解决办法
7206
查看次数

标签 统计

bundle ×1

file ×1

macos ×1

objective-c ×1

xcode ×1