Reputation: 1553
I am trying to pass an object in NSMutablearray to another view's NSmutableArray
I have been looking related question but couldnt figure out whats wrong.
my view switches correctly but it doesnt pass the object in my NSmutable array
- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {
StartHuntViewController *startHuntController = [[StartHuntViewController alloc] initWithNibName:@"StartHuntView" bundle:nil];
startHuntController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:startHuntController animated:YES];;
startHuntController.forStandButton = [stands objectAtIndex:indexPath.row];// doesnt work
// startHuntController.standLocation.text=[stands objectAtIndex:indexPath.row]; // this works
[startHuntController release];
[self.mytableView reloadData];
}
view i am trying to pass data is
.h file
@interface StartHuntViewController : UIViewController<UIApplicationDelegate,CLLocationManagerDelegate,CoreLocationControllerDelegate> {
NSMutableArray *forStandButton;
}
@property (nonatomic, assign)NSMutableArray *forStandButton;
.m file
@synthesize forStandButton;
what should i do ? i guess there is nothing wrong with code?
Upvotes: 0
Views: 327
Reputation: 4914
changed assign to retain, move the line startHuntController.forStandButton = [stands objectAtIndex:indexPath.row];
- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath {
StartHuntViewController *startHuntController = [[StartHuntViewController alloc] initWithNibName:@"StartHuntView" bundle:nil];
startHuntController.forStandButton = [stands objectAtIndex:indexPath.row];
startHuntController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:startHuntController animated:YES];
[startHuntController release];
startHuntController =nil;
}
Upvotes: 0
Reputation: 5038
there are many issues here, for first look :
@property (nonatomic, assign)NSMutableArray *forStandButton;
why property is not retain?
Upvotes: 2
Reputation: 5960
You need to use retain in the property statement. Since forStandButton
is a property of the second view, you want to make sure it is getting set. If you create a setter (setForStandButton
) for it, you can put a break point in the setter method. Once you have confirmed that the setter is being called, make sure it is being retained long enough to be useful.
Upvotes: 0