Problem with a NSString that equals to (null)

Posted by Guy Dor on Stack Overflow See other posts from Stack Overflow or by Guy Dor
Published on 2010-06-15T15:07:43Z Indexed on 2010/06/15 15:12 UTC
Read the original article Hit count: 241

Filed under:
|
|

Hi,

I have an UIViewController named MainViewController I have another UIViewController named LeftSharingViewController;

I would like to get and use the NSString from MainViewController in my LeftSharingViewController

I have a problem, I always get (null) instead of the NSString wanted value.

Here's my code and how does the NSString get it's value MainViewController:

- (void)webViewDidFinishLoad:(UIWebView *)webView {
     leftWebViewString = [NSString stringWithString:leftWebView.request.URL.absoluteString];
}

LeftSharingViewController.h:

#import <UIKit/UIKit.h>
#import "MainViewController.h"
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>

@class MainViewController;
@interface LeftSharingViewController : UIViewController         <MFMailComposeViewControllerDelegate> {
MainViewController *mainViewController;
NSString *leftWebViewUrl;
}

@property (nonatomic, retain) MainViewController *mainViewController;
@property (nonatomic, retain) NSString *leftWebViewUrl;
@end

LeftSharingViewController.m:

#import "LeftSharingViewController.h"
#import "MainViewController.h"

@implementation LeftSharingViewController
@synthesize mainViewController;
@synthesize leftWebViewUrl;
- (void)viewWillAppear:(BOOL)animated {
self.leftWebViewUrl = self.mainViewController.leftWebViewString;
}
#pragma mark -
#pragma mark Compose Mail
-(void)displayComposerSheet 
{
MFMailComposeViewController *mailPicker = [[MFMailComposeViewController alloc] init];
mailPicker.mailComposeDelegate = self;

[mailPicker setSubject:@"Check Out This Website!"];
[mailPicker setMessageBody:[NSString stringWithFormat:@"Take a look at this site:%@", leftWebViewUrl] isHTML:YES];

mailPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:mailPicker animated:YES];
[mailPicker release];

}

Thanks!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c