小编Joe*_*Joe的帖子

在Objective C中,什么相当于在C中传递函数指针?

@implementation ThisObject

-(void)start {

       SomeOtherObject *someOtherObject = [SomeOtherObject alloc];

       [someOtherObject doSomethingAndCallThisFunctionWhenUrDone:myCallBackFunction :self];

}

-(void)myCallBackFunction {

       // :)

}
Run Code Online (Sandbox Code Playgroud)

基本上,我怎样才能做到这一点?

function-pointers objective-c

29
推荐指数
2
解决办法
2万
查看次数

为什么NSString getCharacters不能在xcode中工作?

-(void)myFunction {

        unichar myBuffer[5];
        NSRange range = {0, 3};
        NSString *string = [NSString alloc];
        string = @"123";
        [string getCharacters:myBuffer :range];
}
Run Code Online (Sandbox Code Playgroud)

得到警告

!NSString可能无法响应'-getCharacters ::'

然后在运行时执行SIGABRT.为什么?????或者更好,我怎样才能让它发挥作用?

objective-c nsstring

0
推荐指数
1
解决办法
3228
查看次数

标签 统计

objective-c ×2

function-pointers ×1

nsstring ×1