Reputation: 5259
i know that this is basic objective C question but I have serious problems. I am having an NSMutable array which I fill with values in my connectionDidFinishLoading. i can see in NSLog that values are being assigned correctly. But when i am trying to fetch these values in DidSelectRow (as I am using a table view I get a BAD_ACESS error)
Here is my code:
@implementation MainMap
{
NSMutableArray *condition ;
}
..
- (void)viewDidLoad
{
[super viewDidLoad];
}
...
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
condition= [NSMutableArray array];
..adding objects..
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//app crashes in here
NSLog(@"Condition of pressed item is %@",[condition objectAtIndex:indexPath.row]);
}
If I place the condition= [NSMutableArray array];
inside ViewDidLoad I get a SIGBART
.
Moreover I tried to place the declarations in .h file and have it as property and then synthesize it in .m but still nothing. Maybe I am missing something, so can you fix it?
Upvotes: 0
Views: 68
Reputation: 966
Just try [NSMutableArray new]
instead [NSMutableArray array]
. Then you should release condition
in your dealloc
-method.
Otherwise you can enable ARC (http://longweekendmobile.com/2011/09/07/objc-automatic-reference-counting-in-xcode-explained/). With ARC you must not handle reference counting by yourself.
Upvotes: 2