0

文字列キーと数値を含む plist ファイルがあります。私は、NSDictionary オブジェクトに plist の内容をコードでうまく入力できたと思います。

NSBundle* bun = [NSBundle mainBundle];
NSString* path = [bun pathForResource:@"Tempos" ofType:@"plist"];

tempos = [NSDictionary dictionaryWithContentsOfFile:path];


さて、ここが私が理解していない部分です。

id object = [tempos objectForKey:@"Allegro"];
NSLog(@"bpm: %@", object);

目的の数 を出力します168

NSInteger beats = (NSInteger)[tempos objectForKey:@"Allegro"];
NSLog(@"bpm: %ld", beats);

代わりに、 を出力します43203


さらに重要なことは、私が試したときに

bpm = (NSInteger)[tempos objectForKey:@"Allegro"];

43203配属されbpmます。代わりにどのように168割り当てられbpmますか??

4

1 に答える 1

1

これを使用するとうまくいくと思います:

int beats = [[tempos objectForKey:@"Allegro"] intValue];
NSLog(@"bpm: %i", beats);
于 2012-07-27T16:15:20.093 に答える