我需要访问 viewController 的属性来传递颜色,但是这个属性是 nil。
库视图控制器.h
#import "FinalAlgView.h"
@interface LibraryViewController : UIViewController{
FinalAlgView * drawView;
}
@property (nonatomic, retain)FinalAlgView * drawView;
表格颜色.h
#import <UIKit/UIKit.h>
#import "FinalAlgView.h"
#import "LibraryViewController.h"
@interface TableColor : UITableViewController {
FinalAlgView *color;
LibraryViewController * colorDraw;
}
@property (nonatomic, retain)FinalAlgView *color;
@property (nonatomic, retain)LibraryViewController * colorDraw;
@end
在 TableColor.m 中
- (void)viewDidLoad
{
[super viewDidLoad];
self.colorDraw =[[LibraryViewController alloc]init];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.colorDraw.drawView.lineColor =[UIColor colorWithRed:255.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:0.6];
NSLog(@"the libraryViewController is %@", self.colorDraw);
//the libraryViewController is <LibraryViewController: 0x4d03f0>
NSLog(@"the property is %@", self.colorDraw.drawView);
//the property is (null)
}
我能怎么做?