user16780334
user16780334

Reputation: 502

Unable to pass the value of variable from one class to the another class in Objective c

I have made a helper class for MFMessageComposeViewController so instead of view controller I have made my class with MFMessageComposeViewController as base class.

Now I am trying to present this Controller from my another controller named "ViewController B" on a button action. I am trying to pass the value from this controller to messageBody variable of MessageSSCont.h . The button action is like this :

    self.messageController = [[MessageSSCont alloc]init];
    self.messageController.messageBody = @"jfhjkhasfjhkwhfhdfjkjkfbhiehf";
    [self presentViewController:self.messageController animated:YES completion:nil];

But unfortunately when the MFMessageComposeViewController is presented the value of messageBodyis null. Where I am doing wrong in this scenario. Why my variable is not getting passed to the MessageCont.hclass?

Upvotes: 0

Views: 78

Answers (1)

DonMag
DonMag

Reputation: 77690

OK - you have subclassed MFMessageComposeViewController, so you have its properties / methods available to your class.

You don't need these in your .h file:

//@property (strong, nonatomic) NSString *messageBody;
//@property (strong, nonatomic) NSString *receivingNumber;

You can call your custom MFMessageComposeViewController like this:

self.messageController = [[MessageControllerKony alloc]init];

//self.messageController.messageBody = @"jfhjkhasfjhkwhfhdfjkjkfbhiehf";

[self.messageController setBody:@"jfhjkhasfjhkwhfhdfjkjkfbhiehf"];
[self.messageController setRecipients:[NSArray arrayWithObject: @"13123123"]];

[self presentViewController:self.messageController animated:YES completion:nil];

Upvotes: 1

Related Questions