Home Tutorial Iphone Examples Declaring Method in Objective C

 
 

Declaring Method in Objective C
Posted on: September 30, 2010 at 12:00 AM
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;

Related Tags for Declaring Method in Objective C:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.