有人建议我使用这行代码从我的资源文件夹/项目包中调用图像.我也看到它在许多不同的网站教程中使用完全相同.
NSBundle *mb=[NSBundle mainBundle];
NSString *fp=[mb pathForResource:@"topimage" ofType:@"PNG"];
NSImage *image=[NSImage initWithContentsOfFile:fp];
Run Code Online (Sandbox Code Playgroud)
但是,我收到以下警告:
NSImage可能无法响应+ initWithContentsOfFile +
NSImage的文档显示initWithContentsOfFile实际上是一个应该工作的方法.我可能会在这里失踪什么?