Reputation: 621
I have classes *ColorViewController *DrawRectangle
In ColorViewController.h:
#import "DrawRectangle.h"
@interface ColorViewController : UIViewController {
DrawRectangle *DrawRectangle;
}
@property (nonatomic,retain) DrawRectangle *DrawRectangle;
And in DrawRectangle.h:
@interface DrawRectangle : UIView {
CGFloat redc;
}
@property (nonatomic) CGFloat redc;
I have also added the DrawRectangle class in ViewController.xib to one of UIView.
I want to change the value of CGFloat redc from file ColorViewController.m I'm doing it this way:
- (void)viewDidLoad
{
CGFloat myfloat = 1.0;
self.DrawRectangle.redc = myfloat;
I'm calling NSLog with this 'redc' in DrawRectangle, but it says 0.0000000 each time.
How can I replace the value of 'redc' from ViewController? I don't think I need to use NSNotification, there must be easier way if I have the DrawRectangle loaded into ViewController.
Upvotes: 0
Views: 147
Reputation: 7265
Looks like your object hasn't been instantiated yet. Try:
-(void)viewDidLoad {
[super viewDidLoad];
CGFloat myfloat = 1.0;
[drawRectangle setRedc:myfloat];
}
You should also avoid naming your objects the same name as the class as a general programming practice. I Would suggest renaming the object to drawRectangle
.
You also need to hook up your drawRectangle object in your xib
@property (nonatomic, retain) IBOutlet DrawRectangle *drawRectangle;
Upvotes: 2