I'm having trouble trying to figure out how one would pass information in a UITableViewCell to the view that appears after the button "your play" is pushed. Each cell has the property string gameId associated with it which is unique to each cell and is the information I would like to pass:
The following code shows the creation of the cells. The NSLog statement outputs the correct gameId during testing:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"gameCell";
GameCell *cell = (GameCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
PFObject *myPartners = [self.games objectAtIndex:indexPath.row];
cell.partnerName.text = [myPartners objectForKey:@"receiverName"];
cell.gameId = myPartners.objectId;
NSLog(@"Cell game: %@",cell.gameId);
return cell;
}
In the GameCell class, the following method is used to change the view and pass the gameId: It sets CameraViewControllers property "gameObjectId" equal to "gameId"
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"showCamera"]){
CameraViewController *cameraView = (CameraViewController *)segue.destinationViewController;
cameraView.gameObjectId = self.gameId;
[segue.destinationViewController setHidesBottomBarWhenPushed:YES];
}
}
However when the view loads, the gameObjectId value is null.
Can someone please help me with this?
gameObjectId is in the CameraViewController class as:
@property (strong,nonatomic) NSString *gameObjectId;
gameId is in the GameCell class as:
@property (strong,nonatomic) NSString *gameId;