When i press my button the app crashes. Happens even when I create the button programmatically or try and add one through the XIB for the class where I need the button.
I enabled Zombies and the debug msg I get from the console is :
2010-10-27 00:47:28.643 CarTrawler[1537:207] * -[ReceiptView performSelector:withObject:withObject:]: message sent to deallocated instance 0x76cb700
But the button is added to the view. So I don't understand what the problem is. The class represents a receipt so it gets called depending on how many receipts there are in the app.
- (void)viewDidLoad {
[super viewDidLoad];
self.refLabel.text = theBooking.confID;
self.carTypeLabel.text = theBooking.vehMakeModelName;
//self.amountLabel.text = [NSString stringWithFormat:@"€22.00"];
self.locationLabel.text = [NSString stringWithFormat:@"%@, %@",
theBooking.locationName, theBooking.locationAddress];
self.numberLabel.text = theBooking.locationPhoneNumber;
self.dateTimeLabel.text = theBooking.puDateTime;
self.doDateTimeLabel.text = theBooking.doDateTime;
DLog(@"Dropoff date time label is %@", theBooking.doDateTime);
CTTableViewAsyncImageView *thisImage = [[[CTTableViewAsyncImageView alloc]
initWithFrame:CGRectMake(0.0, 0.0, 64.0, 40.0)] autorelease];
[vendorImage addSubview:thisImage];
NSURL *url = [NSURL URLWithString:theBooking.vehPictureUrl];
[thisImage loadImageFromURL:url];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(220, 270, 60, 30);
[button setTitle:@"Email!" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonPressed)
forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}
-(void)buttonPressed {
NSLog(@"Button Pressed!");
}
Can anybody please explain to me what it is that I have overlooked?