解决方法
宏
#define AssertFileExists(path) NSAssert([[NSFileManager defaultManager] fileExistsAtPath:path],@"Cannot find the file: %@",path) #define AssertNibExists(file_name_string) AssertFileExists([[NSBundle mainBundle] pathForResource:file_name_string ofType:@"nib"])
以下是您尝试加载.xib或.nib之前可以调用的一组宏,它们将帮助识别丢失的文件,并发出有关丢失的信息。
解
使用的实际解决方案是:
if([[NSBundle mainBundle] pathForResource:fileName ofType:@"nib"] != nil) { //file found ... }
请注意,该文档说明ofType:应该是该文件的扩展名。不过即使你使用的是.xib,你需要传递“@”nib“或者你会得到一个假阴性。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。