2014. 1. 3. 15:43 아이폰

포문으로 계속해서 한 함수만 호출할때 

아래와 같은방법을 선언하고 포문에서 함수호출을 하는 방법이 다른 어떤 방법 보다 

심지어 직접 연산을 넣거나 직접 함수를 호출하는 부분 보다 속도가 빠르다고 한다 ...

파라메터가 없을 경우만일거 같은데 .. 책에서는 

파라메터 없는 함수 호출의 경우에서 말했다 

책 objective-c 3판 224페이지 표 8-1


앞으로 무한으로 도는 함수호출의 경우 아래의 경우를 애용해야겠다

1.tydef 선언한경우


typedef int (*f) (id,SEL,int,int);

        f fPoint;

        fPoint = (int(*)(id,SEL,int,int))[self methodForSelector:@selector(testFunctionPoint:B:)];

        NSLog(@"%d",(*fPoint)(self ,@selector(testFunctionPoint:B:),1,2));

2.그냥 사용인 경우

int (*fPoint)(id,SEL,int,int);

        fPoint = (int(*)(id,SEL,int,int))[self methodForSelector:@selector(testFunctionPoint:B:)];

        NSLog(@"%d",(*fPoint)(self ,@selector(testFunctionPoint:B:),1,2));



-(int)testFunctionPoint:(int)a B:(int)b

{

    return a+b;

}

'아이폰' 카테고리의 다른 글

ios 텍스트 이미지 디폴트 공유 - ios shared text image  (0) 2015.04.09
ios auto focus check  (0) 2014.11.18
앱에서 이미지 동영상 겔러리로 저장  (0) 2013.10.28
ios custom keyboard  (0) 2013.06.12
ios arc mrc 설정하기  (0) 2013.03.26
posted by 욱이다