我已经creted一个UIView子类:如何将值从UIViewController传递给UIView?
@interface GraphClass : UIView
{
NSString *str;
}
,我已经指派GraphClass:给名为UIViewController类的观点:
@interface GraphViewController : UIViewController
{
}
现在我想传递的NSString *量,值从另一个
@interface MonthsListController : UIViewController
{
}
in viewDIdLoad
- (void)viewDidLoad
{
GraphClass *graph = [[GraphClass alloc]init];
graph.str = @"abc";
但UIViewController类我得到NULL值,如果我打印GraphClass
STR值-(void)drawRect:(CGRect)rect
{
NSLog(@"Amount is = %@",str);//NULL VAlue :(
}
}
仅有[搜索] (https://www.google.com/search?q=%40property+and+%40synthesize)for @ @ property' and'@ synthesize' ke ywords。 – 2012-02-13 12:54:02
有很多方法可以做到这一点。尝试在'AppDelegate'中使用'str',这样就可以轻松保存或打印值。让我知道它是否有帮助。 – Illep 2012-02-13 12:57:30
是啊阿迪尔我已经设置属性也:(:(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)(#)或代码:( – Shreedhar 2012-02-13 12:57:53