Declaring Method in Objective C


 

Declaring Method in Objective C

In Objective C we can declare two types of methods "Class Method" and "Instance Method" Where + sing denotes the Class method and - sign denotes the Instance method.

In Objective C we can declare two types of methods "Class Method" and "Instance Method" Where + sing denotes the Class method and - sign denotes the Instance method.

Declaring Method in Objective C

In Objective C we can declare two types of methods "Class Method" and "Instance Method" Where + sing denotes the Class method and - sign denotes the Instance method.

For example:

+ (void) printData;
- (void) printData;

The forgoing Objective C methods are declared without parameters. It only takes method type (+ & -), return type (void) and the method name (printData).

You can also declared a method with parameters. Objective C Method also accept more then one parameter. for example…

Objective C method declaration with single parameter:

+ (void) getId: (NSString *) yourId;
- (void) getId: (NSString *) yourId;

Objective C method declaration accepts more than one parameter:

+ (void) getId: (NSString *) yourId andName : (NSString *) yourName;
- (void) getId: (NSString *) yourId andName : (NSString *) yourName;

Ads