我一直想知道的代碼差分零
以下行[self performSelector:@selector(myMethod) withObject:self afterDelay:1.0];
[self performSelector:@selector(myMethod) withObject:nil afterDelay:1.0];
- 請告訴我2行以上的代碼之間的差。
- 什麼時候應該設置對象爲
nil
,我們應該在什麼時候設置對象爲self
?
在大多數情況下,我注意到要設置的對象爲nil
。
閱讀文檔https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/nsobject_Class/Reference/Reference.html –
我已閱讀文檔。我已經在相同的上下文中嘗試了兩行代碼,並且工作正常。所以想知道我找不到Google的區別。 –
- (無效)performSelector:(SEL)aSelector withObject:(ID)anArgument afterDelay:(NSTimeInterval)延遲 anArgument:被調用時的參數傳遞給該方法。通過 如果該方法不帶參數,則爲零。 –