Search code examples
iosobjective-csegueuistoryboardsegueamslidemenu

Unable to pass url string when segue perform using AMSlideMenu?


I am building an article reading app using storyboards.

I am also using AMSlideMenu Library for the main menu. I am facing an problem that is, i want to pass different url values when user click on different rows in AMSlideMenu.

here is my storyboad : enter image description here

here is my code:

   -(NSString *)segueIdentifierForIndexPathInLeftMenu:(NSIndexPath *)indexPath
{
NSString *idetifier = @"firstSegue";
 //   ysTableViewController *str;

switch (indexPath.row) {
    case 0:
        urlString  = @"http://example.com/1";
        break;
    case 1:
                urlString  = @"http://example.com/2";
        break;
    case 2:
                     urlString  = @"http://example.com/3";
        break;
        default:
                     urlString  = @"http://example.com/4";
        break;

}

return idetifier;
}


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Make sure your segue name in storyboard is the same as this line
    if ([[segue identifier] isEqualToString:@"firstSegue"])
    {
        ysTableViewController *controller = (ysTableViewController *)segue.destinationViewController;
        NSLog(@"asgasfg-----%@",urlString);
        controller.Mainlinks = urlString;
    }
}

Solution

  • I got over the problem by using NSUserDefaults temporarily but still it not a proper solution. Still looking for a proper method to pass parameters b/w classes.