Object-c 动态调用函数

项目设计到多个平台,所有底层函数名都是统一的,这就要求IOS这边的函数必须动态执行。

-(void)executefunction:(NSString *)funciontName
{
    NSLog(@"%@",funciontName);
    [self performSelector:(SEL)("test_function")];
    char *f="test_function";
    [self performSelector:(SEL)(f)];
    
    //使用NSString
    [self performSelector:NSSelectorFromString(funciontName)];
    //objc_msgSend(delegateObject, (SEL)method);
}
-(void)test_function
{
    NSLog(@"----fsdaf");
}


posted @ 2012-03-28 17:38  Ethan_村长  阅读(1498)  评论(0编辑  收藏  举报