当我尝试运行它时,Xcode给我一个错误
Thread1: signal SIGABRT
and the console shows: 2012-07-16 11:19:46.401 MyProject[595:11303] (null)
libc++abi.dylib: terminate called throwing an exception
(lldb)
我只是想用表格显示一个视图。 这是我的appDelegate代码:
#import "MyProjectAppDelegate.h"
#import "MyProjectViewController.h"
@implementation MyProjectAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
MyProjectViewController *myProjectViewController = [[MyProjectViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:myProjectViewController];
[[self window] setBackgroundColor:[UIColor whiteColor]];
[[self window] setRootViewController:navController];
[[self window] makeKeyAndVisible];
return YES;
}
我的另一个viewController:
#import "MyProjectViewController.h"
@interface MyProjectViewController ()
@end
@implementation MyProjectViewController
- (id)init{
self = [super initWithStyle:UITableViewStyleGrouped];
if(self){
UINavigationItem *n = [self navigationItem];
n.title = @"MyProject";
UIBarButtonItem *addBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addNewItems:)];
self.navigationItem.rightBarButtonItem = addBarButton;
self.navigationItem.leftBarButtonItem = self.editButtonItem;
}
return self;
}
- (id)initWithStyle:(UITableViewStyle)style
{
return [self init];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tableCell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"tableCell"];
}
cell.textLabel.text = @"OI";
return cell;
}
@end
我已经尝试重置我的模拟器并重启我的Mac。 提前谢谢。