Hi, I'm working through the book "Beginning iPad Development" and it tells me to create an action sheet, and have a couple buttons displayed on it. I get NO errors or warning but when I click build and run, the app automatically crashes and I get this in the debugger
Here is the code for UsingViewController.m:
And for UsingViewController.h
I am absolutely stumped as to why this is causing the app to crash.
Code:
terminate called after throwing an instance of 'NSException'
Here is the code for UsingViewController.m:
Code:
//
// UsingViewsViewController.m
// UsingViews
//
// Created by John on 10-08-19.
// Copyright __MyCompanyName__ 2010. All rights reserved.
//
#import "UsingViewsViewController.h"
@implementation UsingViewsViewController
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"%@", [NSString stringWithFormat:@"%d", buttonIndex]);
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
UIActionSheet *action = [[UIActionSheet alloc]
initWithTitle:@"Title of Action Sheet"
delegate:self
cancelButtonTitle:@"OK"
destructiveButtonTitle:@"Delete Message"
otherButtonTitles:@"Option 1", @"Option 2", nil];
[action showInView:self.view];
[action release];
[super viewDidLoad];
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@end
And for UsingViewController.h
Code:
#import <UIKit/UIKit.h>
@interface UsingViewsViewController : UIViewController
<UIActionSheetDelegate> {
}
@end
I am absolutely stumped as to why this is causing the app to crash.