我在實現由專用框架中的函數使用的對象的實現中實現了C回調,因此我無法控制傳遞給回調函數的參數。我想從回調中使用self
。謝謝。如何從C函數中獲取對象的當前實例
編輯:
MyObject.h/.M
#import "PrivateFramework.h"
@interface MyObject : NSObject
-(void) start;
@end
void callback(void* arg1, int arg2);
void callback(void* arg1, int arg2) {
/*
here I would like to use self (current instance of the object) but
I can't pass a pointer to the instance in the callback since I don't
control what is passed to it.
*/
@implementation MyObject
-(void)start {
// this function is inside a private framework.
PrivateFunction(&callback);
}
@end
這很混亂。請顯示一些代碼。 – 2013-04-26 16:22:08
不好意思,但這是不可理解的。 – 2013-04-26 16:23:56
@ H2CO3我添加了代碼。 – b1onic 2013-04-26 16:37:41