我有一个在启动新视图控制器时设置的属性。
- (IBAction)headerPressed:(UIButton *)sender {
RouteViewController *route = [[RouteViewController alloc] initWithRoute:[[Route getRoute:TEST_ROUTE] autorelease]];
[[self navigationController] pushViewController:circle animated:NO];
}
在新视图中,这是一个 UIViewController
RouteViewController.h
@interface =RouteViewController : UIViewController <MKMapViewDelegate> {
Route *r;
}
-(id)initWithRoute:(Route *)route;
@property (retain, nonatomic) Route *r;
路由视图控制器.m
-(id)initWithRoute:(Route *)route{
self = [super init];
r = route;
return self;
}
- (void)loadView {
[super loadView];
NSLog(@"TEST: %d", r.Route); // throws exception. Actually ANY time I access my r property
}
r.Route 是 constTEST_ROUTE
包含的 int 值。
现在,当我设置断点时,在 NSLog 时,检查器显示我的对象包含
Self >
r >
Route: 1
和
r >
Route: 1
所以该属性是可用的,并且它确实包含正确的数据。但是当我尝试访问该属性时,它会抛出一个 EXC_BAD_ACCESS。
想法?:) (这在杀死我!)