im new in objective c.i have come out with the getter and setter but not sure is correct or not.
.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property(nonatomic, retain) NSString *myText;
@property(nonatomic, copy) NSNumber *opacity;
@property(nonatomic, assign) id delegate;
@end
.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize myText;
@synthesize opacity;
@synthesize delegate;
//getter
-(NSString*)myText{
return myText;
}
-(NSNumber*)opacity{
return opacity;
}
-(id)delegate{
return delegate;
}
//setter
-(void)setMyText:(NSString *)_myText{
if(myText!=_myText){
[myText release];
myText=[_myText retain];
}
}
-(void)setOpacity:(NSNumber *)_opacity{
if (opacity!=_opacity) {
[opacity release];
opacity=[_opacity copy];
}
}
-(void)setDelegate:(id)_delegate{
delegate=_delegate;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end