0

我的 iphone 推特应用程序有问题。当我在表格视图中选择一行时,我的应用程序崩溃并显示“线程 1:程序收到信号”EXC_BAD_ACCESS“。”

这是我的表格视图的代码

//
//  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
4

0 回答 0