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.

 
 

Share on Google+Share on Google+

Declaring Method in Objective C

Ads

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;

Advertisements

Posted on: September 30, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles