0
我試圖在iOS 8中運行此代碼,但我在調用方法中遇到錯誤的訪問錯誤,這在iOS 7中運行正常。有沒有人有關於此的線索?NSInvocation調用在iOS中提供錯誤的訪問8
-(double) calcularColumna:(int) anio :(int) mes :(NSString *) columna {
NSInvocation * invocation = [selectores objectForKey:columna];
if(!invocation){
NSString * metodo = [NSString stringWithFormat:@"fondo%@:anio:mes:",columna];
SEL selector = NSSelectorFromString(metodo);
if(![self respondsToSelector:selector]) {
return -1;
}
invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:selector]];
invocation.selector = selector;
invocation.target = self;
[invocation setArgument:(__bridge void *)(self.valoresEntrada) atIndex:2];
[selectores setObject:invocation forKey:columna];
}
double valor = 0;
[invocation setArgument:&anio atIndex:3];
[invocation setArgument:&mes atIndex:4];
[invocation invoke];
[invocation getReturnValue:&valor];
/* }else {
valor = -1;
}*/
return valor;
}
感謝您的意見。
感謝您的評論,我現在就試試。我無法使用objc_msgSend我得到一個錯誤,告訴我它不能用於C99編譯器。 – 2014-12-02 21:25:32
剛剛經過測試,它的工作:D。隊友的歡呼聲!! – 2014-12-02 21:46:05