Monday, March 5, 2012

How to define private methods in Objective C ?

Ok, I was checking my backlog emails and I found out an interesting question asked by a user:

How to define private methods in Objective C ?

Now different people do it differently, but one the most popular and easiest route is following:
You have a class MyClass, So you want to define a private method say updateText:(NSString *)value,
Here is how you do it.




#import "MyClass.h"

@interface MyClass() 
-(void)updateText:(NSString *)value;
@end


@implementation MyClass
.
.
-(void)someMethod
{

    [self updateText:@"Reetu"];
}
.
.
.
-(void)updateText:(NSString *)value
{
     myLabel.text=value;

.
@end



1 comment:

  1. This is a great post. I like this topic.This site has lots of advantage.I found many interesting things from this site. It helps me in many ways.Thanks for posting this again.
    artificial intelligence internship | best final year projects for cse | internship certificate online | internship for mba finance students | internship meaning in tamil


    ReplyDelete