Iphone IOS TableView选择行崩溃应用程序
我的iphone twiiter应用程序有问题。当我在表视图中选择一行时,我的应用程序崩溃并显示“线程1:程序接收信号”EXC\U BAD\U ACCESS“ 下面是我的表视图的代码Iphone IOS TableView选择行崩溃应用程序,iphone,ios,uitableview,Iphone,Ios,Uitableview,我的iphone twiiter应用程序有问题。当我在表视图中选择一行时,我的应用程序崩溃并显示“线程1:程序接收信号”EXC\U BAD\U ACCESS“ 下面是我的表视图的代码 // // PersonListViewController.m // AssignmentPresenceII // // Created by Waqas Naseem on 8/7/12. // Copyright 2012 __MyCompanyName__. All rights reserved
//
// PersonListViewController.m
// AssignmentPresenceII
//
// Created by Waqas Naseem on 8/7/12.
// Copyright 2012 __MyCompanyName__. All rights reserved.
//
#import "PersonListViewController.h"
@implementation PersonListViewController
@synthesize users;
//@synthesize person;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
self.title=@"People";
}
return self;
}
- (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.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
NSString *path=[[NSBundle mainBundle] bundlePath];
NSString *filePath=[path stringByAppendingPathComponent:@"TwitterUsers.plist"];
self.users=[NSArray arrayWithContentsOfFile:filePath];
//users=[NSArray arrayWithObjects:@"Waqas",@"RAmiz",@"Afnan", nil];
for(NSString *s in users)
{
//NSLog(@"Name : %@",s);
}
//NSArray *array=
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
users=nil;
}
-(void)dealloc
{
[self.users release];
[super dealloc];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.users count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellId=@"Cell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cellId];
if(cell==nil)
{
cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId] autorelease];
}
//NSString *nameString=[self.users objectAtIndex:[indexPath row]];
// NSDictionary *dic=[TwitterHelper fetchInfoForUsername:nameString];
// NSString *displayName=[dic objectForKey:@"name"];
//NSLog(@"Name is %@:",displayName);
//NSString *picURL=[dic objectForKey:@"profile_image_url"];
// NSArray *userTimeLine=[TwitterHelper fetchTimelineForUsername:nameString];
// person=[[Person alloc] initWithUserName:nameString displayName:displayName imgURL:picURL statuses:userTimeLine];
//cell.imageView.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:picURL]]];
//[dic release];
//cell.textLabel.text=nameString;
cell.textLabel.text=@"Hello";
return cell;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"Hi");
}
@end
启用zombie对象并选中enable NSZombie对象并在didSelect函数中设置断点,并检查程序在哪一行崩溃。如何启用NSZombie对象?如果我读对了,您已经注释掉了大部分代码,将显示该表(带有一组“Hello”值),但如果单击它,它将崩溃。如果确实是这样,听起来您已经定义了数据源,但您的委托没有定义。检查Interface Builder中的数据源和委托设置。在Xcode中,在“运行”和“停止”按钮旁边,有一个包含“方案”的下拉列表。单击该选项(左侧的方案名称,而不是右侧的设备/模拟器名称),然后选择“编辑方案”。你会在那里看到启用僵尸。在调试时启用此选项是一件好事(尤其是在不使用ARC的情况下),但我不确定指针是否存在悬空问题。尽管如此,在调试过程中继续进行也是一个不错的选择。