The application is very simple, a nevigationviewcontroller that navigates to a tableview. But when i´m accessing to langsarray, it crashes
Here is the relevant code:
MenuViewController.m
-(void) Settings{
TestViewController *testvc = [[TestViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController setNavigationBarHidden:NO animated:NO];
[self.navigationController pushViewController:testvc animated:YES];
[testvc release];
}
#import <UIKit/UIKit.h>
@interface TestViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
{
NSArray *langsarray;
}
@property (nonatomic, retain) NSArray *langsarray;
@end
#import "TestViewController.h"
@implementation TestViewController
@synthesize langsarray;
- (void)loadView {
//Create the table
UITableView *tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
tableView.delegate = self;
tableView.dataSource = self;
[tableView reloadData];
self.view = tableView;
//read the info
NSString *path = [[NSBundle mainBundle] pathForResource:@"l" ofType:@"txt"];
NSString *langs = [[NSString alloc]initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
langsarray = [langs componentsSeparatedByString: @"\n"];
[path release];
[langs release];
[tableView release];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//Accessing langsarray crash the app
//harcoded works fine: return 5;
return [langsarray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:
SimpleTableIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:SimpleTableIdentifier] autorelease];
}
NSUInteger row = [indexPath row];
// again, accessing langsarray crash the app
cell.textLabel.text = [[[langsarray objectAtIndex:row] componentsSeparatedByString:@"="] objectAtIndex:0];
cell.detailTextLabel.text = [[[langsarray objectAtIndex:row] componentsSeparatedByString:@"="] objectAtIndex:1];
return cell;
}
This is the output
Program received signal: “EXC_BAD_ACCESS”. warning: Couldn't find minimal symbol for "_sigtramp" - backtraces may be unreliable kill
Xcode 3.1.4 leopard