When I put this in my MainViewController.m file, it causes a build error.
Here's what I want to do. There's a void in my MainViewController.m file that I want to be able to call from MainView.m. This void needs to display the in-app email form.
MainViewController.h
Code:
- (void)showEmailModalView:(NSString*) storyText;
This is the function I want to call. storyText is the string that I want to display in the body of the email.
MainView.h
Code:
#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
@class MainViewController;
@interface MainView : UIView {
IBOutlet UITextField *userName;
IBOutlet UISegmentedControl *userGender;
IBOutlet UITextView *storyBox;
MainViewController *controller;
}
@property (nonatomic, retain) MainViewController *controller;
MainView.m
Code:
#import "MainView.h"
#import "MainViewController.h"
//import email sheet stuff
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
@implementation MainView
@synthesize controller;
//bunch of other program code
//email function
-(IBAction)emailStory {
//check if user entered a name
NSLog(@"MainView.m -(IBAction)emailStory called");
if(storyName==nil) {
//display warning
} else {
NSString *storyTextToEmail = [storyBox text];
[controller showEmailModalView:storyTextToEmail];
}
}
XCode isn't giving me warnings or errors, but when I put self.view.controller = self; or MainView.controller = self; in the viewDidLoad as stated above, it gives me errors.
If I use self.view.controller = self;, XCode says
error: request for member 'controller' in something not a structure or union
If I use MainView.controller = self;, XCode says
error: accessing unknown 'setController:' class method
error: object cannot be set - either readonly property or no setter found
Any suggestions? I'm completely stumped by this.