Quote:
Originally Posted by scrumsolutions
Hi All,
When a user clicks on a disclosure button in a cell in my UITableView, I want to be able to pass over a record ID so that I can use that as a reference to the item being viewed;
Code:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
NSString *record = [contentsList objectAtIndex:[indexPath row]];
addUS *editRecord = [[addUS alloc] init];
editRecord.editID = record;
[self presentModalViewController:[clsNavigation viewAddUS] animated:YES];
}
editID is in the addUS class, but when I debug and point a breakpoint on that property, the property has no value. When I check the *record though there is value.
Can you help?
|
You are creating an addUS object as a local variable, and then not doing anything to pass it to the other view controller (or anywhere outside of this method.) When you create a local variable, it's "scope" (the range of code that can use that variable) is limited to only the method.
If you want to pass your addUS object to the view controller you are invoking, add an addUS property to the other view controller, and set it before invoking the view controller.
I gather that [clsNavigation viewAddUS] is a method call that returns a view controller?
If so, add a new property to that view controller. Let's call it theEditRecord. You would add code like this to the header of your view controller
Code:
@interface secondViewController; //replace with the class of view controller you're using
{
//Other ivars that are already in the class go here...
addUS *theEditRecord;
}
//Other property declarations would go here..
@property (nonatomic, retain) addUS *theEditRecord;
//Other method declarations would go here...
@end
and add "@synthesize theEditRecord" to the implementation of your view controller.
Then you could say:
Code:
[clsNavigation viewAddUS].theEditRecord = addUS;
[self presentModalViewController:[clsNavigation viewAddUS] animated:YES];