저는 항상이 문제에 대해 궁금해했습니다. 맞춤 클래스에 점 표기법 사용
내가
는@property
라는 hitCounter을 가지고이 잘 작동합니다 :
if ([[someArray objectAtIndex:i] hitCounter]!=0) continue;
문제 없음, 그것은 작동합니다. 필자가 작성한 getter 메소드 hitCounter
이 없습니다. @synthesize
때문에 거기에 있습니까?
그러나 속성은 점 표기법을 허용해야합니다. 속성이 존재하더라도, 합성,이 배열의 객체에 대한 클래스 헤더를 가져온 다음 컴파일의도 :
if ([someArray objectAtIndex:i].hitCounter!=0) continue;
또는
if ((MyClass*)[someArray objectAtIndex:i].hitCounter!=0) continue;
는 컴파일러는 말한다 property hitCounter not found on object of type id
하지만 분명히 내가 MyClass
으로 전송하므로 더 이상 입력하지 않아야합니다. id
- 여기 무슨 일이 일어나나요?