我正试着从infoDictionary中检索一些URLs。10次中有9次正确返回URLs。但是,在极少数情况下,URLs会返回nil。你知道是什么导致了这种行为吗?
当这种奇怪的行为发生时,[NSBundle mainBundle]和[[NSBundle mainBundle] infoDictionary]都不是空的。只有URLs返回nil。
发布于 2014-05-12 20:40:20
在iOS中,不可能写入应用程序包,因此尝试这样做将失败。通常情况下,数据是从应用程序的文档目录中的文件中写入和读取的,可以按如下方式获取:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths firstObject];
NSString *filePath = [documentsDirectory stringByAppendingPathComponent:myFileName];https://stackoverflow.com/questions/23600466
复制相似问题