1
所以,我試圖在另一個對象中調用方法,並將調用對象作爲調用的一部分傳遞。可能是我架構,它只是沒有任何意義的方式,但無論如何,這裏的電話:Objective-C:編譯器錯誤將自身傳遞給選擇器中的方法
NSTimer *refreshTimer = [NSTimer
scheduledTimerWithTimeInterval:[timerDate timeIntervalSinceNow]
target:otherObject
selector:@selector(methodBeingCalled:self)
userInfo:nil
repeats:NO];
和接收方法具有以下特徵:
- (void)methodBeingCalled:(id)sender;
當我這樣做,我得到呼叫中出現錯誤,說「預計錯誤」:'「。這對我來說沒有意義,因爲我在那裏有一個冒號來傳遞「self」作爲參數。
我是否正確使用選擇器?我應該使用NSInvocation嗎?
太棒了,謝謝你的提示。 所以,如果我理解正確,只是做@selector(methodBeingCalled :)會將Timer對象本身發送給methodBeingCalled? –
是的,這是正確的 – borrrden
很酷。再次感謝! –