0

私のアプリケーションでは、以下のコードを使用して plist を取得できません。私はXcode 4.5を使用しています.plistを取得するためのコードは次のとおりです。

    NSBundle *thisBundle = [NSBundle mainBundle];
    NSDictionary *theDictionary;
    NSString *commonDictionaryPath;
    if (commonDictionaryPath = [thisBundle pathForResource:@"newfonts-Info" ofType:@"plist"])
    {
        theDictionary = [[NSDictionary alloc] initWithContentsOfFile:commonDictionaryPath];
    }

注:-テキストまたは xml ファイルを取得しようとすると、上記のコードは正常に機能します。

4

4 に答える 4

0

最後に自分で答えを見つけます

ドキュメント ディレクトリを開いて application.app ファイルを開くとapplication-Info.plist、バンドルに表示されている plist ファイルがそのまま表示されることがわかりました。Info.plist

上記のコードを変更して、辞書を取得します

NSString *commonDictionaryPath;
commonDictionaryPath=[[NSBundle mainBundle]pathForResource:@"Info" ofType:@"plist"];
NSDictionary *info=[NSDictionary dictionaryWithContentsOfFile:commonDictionaryPath];
NSLog(@"path %@",commonDictionaryPath);
于 2013-05-23T14:01:00.100 に答える