0
인스턴스를 저장하여 다른 방법으로 사용할 수있는 방법은 무엇입니까? 이것은 내가 가지고있는 코드 :둘 이상의 메서드에서 인스턴스 변수 사용
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint touchedStart;
// find position of the touch
touchedStart = [[touches anyObject] locationInView:self];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint touchedEnd;
// find position of the touch
touchedEnd = [[touches anyObject] locationInView:self];
}
나는 touchesEnded
방법에 touchedStart
변수를 사용할 수 있어야합니다. 어떻게하면 좋을까요?
멤버 변수 란 무엇입니까? – Joshua
@Joshua - 여러분이 지금 가지고있는 "지역 변수"와 반대로 클래스의 멤버 인 변수 (인스턴스 변수라고도 함)입니다. –
예, 제가 조금 혼란스러워한다는 것을 아는 것이 무엇인지 압니다. 감사! – Joshua