iWizard
iWizard

Reputation: 7104

How to send object from one to another view?

I have implemented SASlideMenu for side menu and is excellent everything except one thing. I don't know how to send object.

Here is switching view happening:

-(void) switchToContentViewController:(UIViewController*) content{

    CGRect bounds = self.view.bounds;
    if (selectedContent) {


        //Animate out the currently selected UIViewController
        [UIView animateWithDuration:kSlideOutInterval delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^{
            selectedContent.view.frame = CGRectMake(bounds.size.width,0,bounds.size.width,bounds.size.height);
        } completion:
         ^(BOOL completed) {

             [selectedContent willMoveToParentViewController:nil];
             [selectedContent.view removeFromSuperview];
             [selectedContent removeFromParentViewController];

             content.view.frame = CGRectMake(bounds.size.width,0,0,bounds.size.height);
             [self addChildViewController:content];
             [self.view addSubview:content.view];
             [UIView animateWithDuration:kSlideInInterval delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^{
                 content.view.frame = CGRectMake(0,0,bounds.size.width,bounds.size.height);

             } completion:^(BOOL completed){
                 selectedContent = content;
                 [content didMoveToParentViewController:self];
                 [self.shield removeFromSuperview];
             }];
         }];
    }else{
        [self addChildViewController:content];
        [self.view addSubview:content.view];
        content.view.frame = CGRectMake(0,0,bounds.size.width,bounds.size.height);
        selectedContent = content;
        [self.shield removeFromSuperview];
        [content didMoveToParentViewController:self];
    }
}

and what I want is here to get identifier (NSString) (that I will know how to solve) and then send to this new view controller which will be open.

How can I do that?

Upvotes: 0

Views: 151

Answers (1)

user1078170
user1078170

Reputation:

You can use a subclass of UIViewController instead of the stock UIViewController class for your "content" view controller. On this subclass, you can add a

@property (strong, nonatomic) NSString *stringForContentView;

Then, just above the line where you add the "content" view controller as a child of your current view controller,

content.stringForContentView = @"A string that you already have";

Upvotes: 1

Related Questions