error: expected identifier or '(' before 'public' - objective C -


i getting error when declare instance variable

@interface foo : nsobject {  @public   int a; } @public -(id)init; -(void)dealloc; @end 

error: expected identifier or '(' before 'public'

you not use @public or other access keywords outside interface definition, don't declare public or private methods in objective-c.

as long expose method in header/interface it's automatically publicly accessible outside class. if add implementation, don't expose in header/interface (or expose in class extension), it's private.

@interface foo : nsobject { @public     int a; }  - (id)init; - (void)dealloc;  @end 

now why want declare public int a instance variable (instead of using property) or explicitly declare 2 methods nsobject has beyond me.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -