Hi,
I have an UIWebView in my A view controller for example.
I want to use this UIWebView in my B view controller subclass, for some reason I get this error:
"request for member 'request' in something not a structure or union"
Here is my code:
mainViewController .h (which called A view controller)
and of course @synthesize for both of them.
Here is my scondViewController .h (which called B view controller
.m scondViewController
Thanks!
I have an UIWebView in my A view controller for example.
I want to use this UIWebView in my B view controller subclass, for some reason I get this error:
"request for member 'request' in something not a structure or union"
Here is my code:
mainViewController .h (which called A view controller)
Code:
@interface mainViewController : UIViewController <MFMailComposeViewControllerDelegate> {
UIWebView *leftWebView;
UIWebView *rightWebView;
}
@property (nonatomic, retain) IBOutlet UIWebView *leftWebView;
@property (nonatomic, retain) IBOutlet UIWebView *rightWebView;
@end
and of course @synthesize for both of them.
Here is my scondViewController .h (which called B view controller
Code:
@class mainViewController;
@interface rightSharingViewController : UIViewController {
NSString *leftWebViewUrl;
NSString *rightWebViewUrl;
mainViewController *leftWebView;
mainViewController *rightWebView;
}
@property (retain) NSString *leftWebViewUrl;
@property (retain) NSString *rightWebViewUrl;
@property (retain) mainViewController *leftWebView;
@property (retain) mainViewController *rightWebView;
- (void)doneButton:(id)sender;
- (void)safariButton:(id)sender;
- (void)mailButton:(id)sender;
- (void)leftLaunchMailAppOnDevice;
- (void)rightLaunchMailAppOnDevice;
- (void)displayLeftComposerSheet;
- (void)displayRightComposerSheet;
@end
.m scondViewController
Code:
#import "rightSharingViewController.h"
#import "mainViewController.h"
@implementation rightSharingViewController
@synthesize leftWebViewUrl;
@synthesize rightWebViewUrl;
@synthesize leftWebView;
@synthesize rightWebView;
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
- (void)doneButton:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
- (void)safariButton:(id)sender {
}
- (void)mailButton:(id)sender {
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
if ([mailClass canSendMail])
{
[self displayRightComposerSheet];
}
else {
[self rightLaunchMailAppOnDevice];
}
}
else {
[self rightLaunchMailAppOnDevice];
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return YES;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma mark -
#pragma mark Compose Mail
-(void)displayLeftComposerSheet {
MFMailComposeViewController *leftPicker = [[MFMailComposeViewController alloc] init];
leftPicker.mailComposeDelegate = self;
[leftPicker setSubject:@"A Website to Share With You"];
//mainViewController.leftWebView = leftWebView;
leftWebViewUrl = leftWebView.request.URL.absoluteString;
NSString *leftEmailBody = [[NSString alloc] initWithFormat:@"Hi, I would like to share with you this link: %@", leftWebViewUrl];
[leftPicker setMessageBody:leftEmailBody isHTML:NO];
[self presentModalViewController:leftPicker animated:YES];
[leftPicker release];
}
-(void)displayRightComposerSheet {
MFMailComposeViewController *rightPicker = [[MFMailComposeViewController alloc] init];
rightPicker.mailComposeDelegate = self;
[rightPicker setSubject:@"A Website to Share With You"];
rightWebViewUrl = rightWebView.request.URL.absoluteString;
NSString *rightEmailBody = [[NSString alloc] initWithFormat:@"Hi, I would like to share with you this link: %@", rightWebViewUrl];
[rightPicker setMessageBody:rightEmailBody isHTML:NO];
[self presentModalViewController:rightPicker animated:YES];
[rightPicker release];
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
switch (result) {
case MFMailComposeResultCancelled:
break;
case MFMailComposeResultSaved:
break;
case MFMailComposeResultSent:
break;
case MFMailComposeResultFailed:
break;
default:
break;
}
[self dismissModalViewControllerAnimated:YES];
}
-(void)leftLaunchMailAppOnDevice {
MFMailComposeViewController *leftPicker = [[MFMailComposeViewController alloc] init];
[leftPicker setSubject:@"A Website to Share With You!"];
leftWebView.request.URL.absoluteString;
NSString *emailBody = [[NSString alloc] initWithFormat:@"Hi, I would like to share with you this link: %@", leftWebViewUrl];
[leftPicker setMessageBody:emailBody isHTML:NO];
NSString *email = [NSString stringWithFormat:@"%@", emailBody];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
-(void)rightLaunchMailAppOnDevice {
MFMailComposeViewController *rightPicker = [[MFMailComposeViewController alloc] init];
[rightPicker setSubject:@"A Website to Share With You!"];
rightWebView.request.URL.absoluteString;
NSString *emailBody = [[NSString alloc] initWithFormat:@"Hi, I would like to share with you this link: %@", rightWebViewUrl];
[rightPicker setMessageBody:emailBody isHTML:NO];
NSString *email = [NSString stringWithFormat:@"%@", emailBody];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
[leftWebViewUrl release];
[rightWebViewUrl release];
[leftWebView release];
[rightWebView release];
}
@end
Thanks!