1

ネストされた辞書を含むplistファイルから文字列を取得しようとしています。これはplistです:

<dict>
    <key>DataPoints</key>
    <array>
        <dict>
            <key>source</key>
            <string>BloomBerg</string>
            <key>date</key>
            <date>2010-01-31T14:54:13Z</date>
            <key>value</key>
            <integer>1233</integer>
        </dict>
        <dict>
            <key>source</key>
            <string>BloomBerg</string>
            <key>date</key>
            <date>2010-02-02T14:54:13Z</date>
            <key>value</key>
            <integer>1235</integer>
        </dict>
        <dict>
            <key>source</key>
            <string>BloomBerg</string>
            <key>date</key>
            <date>2010-01-31T14:54:13Z</date>
            <key>value</key>
            <integer>1230</integer>
        </dict>
    </array>
</dict>

これが私のコードです:

NSString *path = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"sampledata.plist"];
NSDictionary* plotDictionary = [[NSDictionary dictionaryWithContentsOfFile:path] retain];
NSArray* plotData = [plotDictionary objectForKey:@"DataPoints"];

NSLog(@"Got the dict %d",[plotData count]);

NSDictionary* plotPoint = [plotData objectAtIndex:1];

NSLog(@"Got the point %d",[plotPoint count]);

NSString* source = [plotPoint objectForKey:@"source"]; 
NSLog(@"...", source);

配列とdictのカウントは取得しますが、文字列の値は取得しません。おそらく何か単純な間違いをしている...

4

1 に答える 1

3

最後の行、あなたは置きNSLog(@"…", source);ます。したくないですNSLog(@"%@", source);か?

于 2010-01-31T17:04:33.433 に答える