I keep getting "EXC_BAD_ACCESS" the second time I set an NSString using the stringByAppendingString-method.
I've tried reading up on this error, and from what I can gather it has to do with the variable not being retained.
So to remedy that I went ahead and declared the string and made it a property (using nonatomic, retain) in the h-file as such:
DetailViewController.h
And then synthezized it in the m-file as such:
DetailViewController.m
But despite making my string retained, in the second if-else-statment (which is run an iteration after the first if-statement), attempting to append the string results in the error.
Btw, the didSelectRow does NOT pass the scene over to another view, but remains the active view (the table simply reloads with new data from another plist).
I've tried reading up on this error, and from what I can gather it has to do with the variable not being retained.
So to remedy that I went ahead and declared the string and made it a property (using nonatomic, retain) in the h-file as such:
DetailViewController.h
Code:
...
@interface RootViewController : UITableViewController {
NSString *str_CurrentPlist;
}
@property (nonatomic, retain) NSString *str_CurrentPlist;
...
And then synthezized it in the m-file as such:
DetailViewController.m
Code:
...
@synthesize str_CurrentPlist;
...
- (void)viewDidLoad
{
...
str_CurrentPlist = @"MENU";
}
...
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([str_CurrentLevel isEqualToString:@"1"]) // Runs first time
{
str_CurrentLevel = @"2";
str_CurrentPlist = [str_CurrentPlist stringByAppendingString:@"_L"];
tempRow = [NSString stringWithFormat: @"%d", (indexPath.row + 1)];
str_CurrentPlist = [str_CurrentPlist stringByAppendingString:tempRow]; // Log p
outputs "MENU_L1", for instance
}
else if ([str_CurrentLevel isEqualToString:@"2"]) // Runs second time
{
str_CurrentLevel = @"3";
// Generates EXC_BAD_ACCESS
str_CurrentPlist = [str_CurrentPlist stringByAppendingString:@"_D"];
}
}
But despite making my string retained, in the second if-else-statment (which is run an iteration after the first if-statement), attempting to append the string results in the error.
Btw, the didSelectRow does NOT pass the scene over to another view, but remains the active view (the table simply reloads with new data from another plist).