Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i have created a script, witch load the XML from server parse it an save it to NSMutableArray

[kategorienArray addObject:catName];

catName ist a String, if i NSLog the Array everything works fine.

After that i have created a tebleview, and reload Data

[kategorienAuswahl reloadData];

KategorienAuswahl is my TableView

and now a get the Problems

if i Use a "normal" array

NSArray *array = [[NSArray alloc] initWithObjects:@"iPhone", @"iPod", @"iPad",nil];
    self.listData = array;
    [array release];

the will be displayed, but if i use

cell.textLabel.text = [kategorienArray objectAtIndex:row]; 

i get EXC_BAD_ACCESS

instead it works fine with

cell.textLabel.text = [listData objectAtIndex:row]; 

I Add nwo

kategorienArray = [[NSMutableArray alloc] init];
    kategorienArray = [NSMutableArray arrayWithCapacity:10];

but now i get no data in my Tableview

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
236 views
Welcome To Ask or Share your Answers For Others

1 Answer

You might not have initialized your kategorienArray. Do you have a kategorienArray = [[NSMutableArray alloc] init]; in your code? You should have done this before adding objects to it and then accessing them.

Also, make sure your array is retained at the point where it's created, so that the system doesn't reclaim its memory before you access its items. The way I use to make sure things are going right is to declare the mutable array as a property. In your viewcontroller's .h file put

@property (nonatomic, retain) NSMutableArray *kategorienArray;

and in your .m file put

@synthesize kategorienArray;

at the top and then

self.kategorienArray = [NSMutableArray array];

in viewDidLoad or somewhere, before adding items to it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...