Reputation: 271
i have creted a UIView Subclass:
@interface GraphClass : UIView
{
NSString *str;
}
And i have assigned GraphClass: to a View of an UIViewController Class named:
@interface GraphViewController : UIViewController
{
}
Now i want to pass NSString *amount,value from another UIViewController Class
@interface MonthsListController : UIViewController
{
}
in viewDIdLoad
- (void)viewDidLoad
{
GraphClass *graph = [[GraphClass alloc]init];
graph.str = @"abc";
But am getting NULL value if i print str Value in GraphClass
-(void)drawRect:(CGRect)rect
{
NSLog(@"Amount is = %@",str);//NULL VAlue :(
}
}
Upvotes: 2
Views: 1003
Reputation: 1
#import "GraphClass.h"
// in UIViewController Class
GraphClass *graph = [[GraphClass alloc] init];
graph.recStr=Amount;
[self.view addSubview:graph];
// In GraphClass
@interface GraphClass : UIView
{
NSString *recStr;
}
@propery (nonatomic,strong) NSString *recStr;
Upvotes: 0
Reputation: 16841
MonthsListController.h
#import GraphClass.h
GraphClass *graph;
@property(nonstatic,retain)GraphClass *graph;
MonthsListController.m
@synthesis graph;
viewDidLoad
self.graph= [[GraphClass alloc]init];
[self.graph str:@"xx"];
-(void)drawRect:(CGRect)rect
NSLog(@"%@",graph.str);
Upvotes: 2