이것은 아마도 내 편에서는 오류입니다. 그러나 이것이 키 경로로 식별 된 속성의 유형 인 int를 반환하지 않는 이유는 조금 혼란 스럽습니다. valueForKeyPath : 대신 객체를 반환합니다. 아무나 설명 할 수 있습니다.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'
호퍼 호퍼 * = [ALLOC] INIT]을; Hopper * 호퍼 = [[Hopper alloc] init]이어야합니다. – CarlJ
감사합니다. meccan, 제 실수는 Xcode에서 붙여 넣었어야했는데 그냥 여기에 신선한 코드를 입력해야했습니다. 나는 그 질문을 갱신했다. – fuzzygoat