Objective c 如何在Mac OS X上读取另一个应用程序的plist文件?
我正在创建一个插件到另一个应用程序,我想访问一个plist文件 我尝试了以下操作,但找不到该文件Objective c 如何在Mac OS X上读取另一个应用程序的plist文件?,objective-c,macos,bundle,plist,Objective C,Macos,Bundle,Plist,我正在创建一个插件到另一个应用程序,我想访问一个plist文件 我尝试了以下操作,但找不到该文件 NSBundle* bundle = [[NSBundle mainBundle] initWithPath:@"~/Library/Containers/com.Apple.Externalapp/"]; NSString* filePath = [bundle pathForResource:@"container" ofType:@"plist"]; if ([[NSFileManager
NSBundle* bundle = [[NSBundle mainBundle] initWithPath:@"~/Library/Containers/com.Apple.Externalapp/"];
NSString* filePath = [bundle pathForResource:@"container" ofType:@"plist"];
if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
NSLog(@"File exists");
} else {
NSLog(@"File doesn't exist");
}
我做错了什么?您从
[NSBundle mainBundle]
开始。该方法返回应用程序的NSBundle,完全初始化。您向该初始化包发送一条initWithPath
消息;从那时起事情会变得非常糟糕
您可能需要[[NSBundle alloc]initWithPath…]