Here is my code, posted in view1:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Make sure your segue name in storyboard is the same as this line
if ([segue.identifier isEqualToString:@"toLevels"])
{
levelViewController *vc = [segue destinationViewController];
vc.currentEnchantmentSelected = self.title;
}
}
This doesn’t send the value of “self.title” to the variable in “levelViewController”. Why is this? It sends it if I use a string.
Edit (levelViewController):
@synthesize enchantment = _enchantment;
- (enchantmentViewController *)enchantment
{
if (!_enchantment){
_enchantment = [[enchantmentViewController alloc] init];
}
return _enchantment;
}
the @property enchantment is declared in the header.
So from the chat, the issue was that you were setting this property in
didSelectRowAtIndexPath:, which is actually called afterprepareForSegue:sender:with storyboards. (when the segue is attached to a cell in a table)So the solution is just to do that work directly in
prepareForSegue:sender:instead. Thesenderwill be the cell that was tapped. And if you need the indexPath for that cell you can use:Good luck with the app.