0
Xcode是期待一個 ')' 之前的YES工作時間表如何使用選擇器和參數?
[_creep scheduleOnce:@selector(removeFromParentAndCleanup:YES) delay:2.0f];
很抱歉,如果它似乎基本的東西...我剛開始的ObjectiveC。
Xcode是期待一個 ')' 之前的YES工作時間表如何使用選擇器和參數?
[_creep scheduleOnce:@selector(removeFromParentAndCleanup:YES) delay:2.0f];
很抱歉,如果它似乎基本的東西...我剛開始的ObjectiveC。
因爲科科斯API限制你一個選擇1個參數(ccTime),編寫可以通過給定的參數,以適當的功能你自己的方法:
-(void)doneWithSomething {
[self scheduleOnce:@selector(removeAndCleanup:) delay:2.0f];
}
-(void)removeAndCleanup:(ccTime)delta {
[ _creep removeFromParentAndCleanup:YES];
}
你不能傳遞參數在@selector()
指令,因爲它直接關聯到vTable(用於常用方法)或ObjC sel高速緩存中的條目中的條目,因此編譯器認爲您試圖調用名爲-removeFromParentAndCleanup:YES
的不可信名稱方法您不會將參數傳遞給一個選擇器,它們在選擇器被調用時傳遞。 – 2013-03-08 15:40:42
你可以顯示'removeFromParentAndCleanup'的聲明嗎? – 2013-03-08 15:40:49
這是cocos2d的東西:http://www.cocos2d-iphone.org/api-ref/latest-stable/interface_c_c_node.html#a0d4e615f688458c74001acf10f0ae011 – 2013-03-08 15:42:18