2016-08-15 49 views
2

我想讀取包含在我自己創建的框架info.plist中的文件。當我嘗試閱讀時,rferans已經讀取了他的文件info.plist框架應用程序。在定製框架中讀取info.plist

我需要閱讀兩者。我該怎麼做?你能幫忙嗎?

NSLog(@"*** %@", [[[NSBundle mainBundle] localizedInfoDictionary] valueForKey:@"ASD"]); 
NSLog(@"*** %@", [[[NSBundle mainBundle] infoDictionary] valueForKey:@"ASD"]); 
NSLog(@"*** %@", [[[[NSBundle allFrameworks] objectAtIndex:0] infoDictionary] valueForKey:@"ASD"]); 

Framework Screenshot

App Screenshot

+0

因爲你需要與路徑得到這個象下面這樣: '的NSString *路徑= [[一個NSBundle mainBundle] pathForResource:@ 「YOURPLISTNAME」 ofType:@「的plist 「]; NSMutableDictionary * dictplist = [[NSMutableDictionary alloc] initWithContentsOfFile:path];' – CodeChanger

回答

3

首先使用你的框架路徑創建捆綁:

NSString* mainBundlePath = [[NSBundle mainBundle] resourcePath]; 
NSString* frameworkBundlePath = [mainBundlePath stringByAppendingPathComponent:@"YourFrameworkBundle.bundle"]; 
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath]; 

然後訪問信息字典或者你想

1

謝謝你的答案是什麼。

解決方案如下所示:

[[[NSBundle bundleForClass:[self class]] infoDictionary] objectForKey:@"ASD"]