One source code extension
Class II2.1 Definitions
@interface Person:nsobject//class person inheritance NSOBJETCT @end
The methods and properties defined in the class are written in the middle of @interface [email protected]
The @ here is for the compiler to find and pre-compile processing
property declaration of the class
@interface**lastName;
@property int Yearofbirth; base int type, is a value type
@property (readonly) NSString *firstname; is a read-only property @end
Minus method declaration ( common method also known as Object Method )
@interface person:nsobject-(void) SomeMethod;//void is the return value type -(void) Somemethodwithvalue (SomeType) value; -(void) Somemethodwithfirstvalue: (SomeType) Info1secondvalue: (Anothertype) Info2; @end
Plus method declaration ( class method also known as static method )
@interface nsstring:nsobject+ (ID)string; + (ID) stringwithstring: (nsstring*) astring; @end
Implementation of the class
#import " XYZperson.h " @implementation @end
Declare class with interface, implement class with implementation.
iOS Grammar basic Syntax overview