新手提問,看別人的代碼是這樣寫的:
@interface FirstViewController() -(void)timerOnActive; -(void)getDataFromCD; @end @implementation FirstViewController @synthesize userID; @synthesize timer;
上面的代碼是寫在.m文件里的,我的問題是為什么不把
@interface FirstViewController() -(void)timerOnActive; -(void)getDataFromCD; @end
寫在.h文件的@interface中? FirstViewController() 后面的那個(gè)括號(hào)是空的,需要填什么嗎?這樣寫是為了補(bǔ)充嗎?
小伙看你根骨奇佳,潛力無限,來學(xué)PHP伐。
The @interface FirstViewController() here is actually a class extension, just like an anonymous category. The methods it declares must be implemented in the main @implementation code block of the corresponding class. A class may have a publicly declared API , while having additional methods declared as private for use only by the class or framework class. You can declare such a method using a category (or more than one category) in a private header file or implementation file mentioned above. This works, but the compiler cannot confirm that all declared methods are implemented.
The method written in the m file cannot be called by external classes. This method is treated as a private method and called within this class. It is hidden from the outside world.