これはおそらく私の側のパイロット エラーですが、なぜこれが int を返さないのか少し混乱しています (キー パスによって識別されるプロパティの型であるため)。valueForKeyPath: は代わりにオブジェクトを返しますか? 誰でも説明できますか?
// Simple Object
@interface Hopper : NSObject
@property(nonatomic, assign) int mass;
@end
// Test
Hopper *hopper = [[Hopper alloc] init];
[hopper setMass:67];
NSLog(@"HOPPER: %d", [hopper valueForKeyPath:@"mass"]);
.
WARNING: Conversion specifies type 'int' but the argument has type 'id'