开发者

Using an Instance Variable in more than one method

How would I save an Instance so that I could use it in another method? This is the code I have:

- (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];

}

I want to be able to use the touchedStart variable in the touchesEnded method. How would I do this?


Just make it a member variable in the class itself - then the other method will be able to access it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜