zoukankan      html  css  js  c++  java
  • NSInvocation 回调使用

    声明
    NSInvocation* m_touchDown;


    赋值
    -(void) setTouchMoveCallback:(id) target sel:(SEL) sel {
        if (m_touchMove) {
            [m_touchMove release];
            m_touchMove = nil;
        }
        NSMethodSignature *sig= [target methodSignatureForSelector:sel];
        NSAssert(sig, @"");
        m_touchMove = [NSInvocation invocationWithMethodSignature:sig];
        [m_touchMove setTarget:target];
        [m_touchMove setSelector:sel];
        [m_touchMove setArgument:&self atIndex:2];
        [m_touchMove retain];
    }


    开始回调
    - (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
    {
        if (m_touchDown) {
            [m_touchDown setArgument:&touch atIndex:3];
            [m_touchDown setArgument:&event atIndex:4];
            [m_touchDown invoke];
        }
        return YES;
    }


    使用
    [btn setTouchDownCallback:self sel:@selector(eventTouchBegin:touch:event:)];


    回调函数

    -(void) eventTouchBegin:(myButton*) sender touch:(UITouch*) touch event:(UIEvent*) event {
       // TODO
    }




  • 相关阅读:
    hdu 3367 Pseudoforest
    hdu 2489 Minimal Ratio Tree
    hdu 4009 Transfer water
    poj 3164 Command Network
    hdu 3926 Hand in Hand
    hdu 3938 Portal
    5-26日(面经总结)
    5-25日
    5-21日|5-22日
    5-13日记录|5-14日
  • 原文地址:https://www.cnblogs.com/iapp/p/3631724.html
Copyright © 2011-2022 走看看