iphone - Problem with a NSString that equals to (null) -


I have another UIViewController named LeftSharingViewController;

I want to get and

I have a problem, I always want NSString (faucet) instead of the desired value.

Here's my code and NSString How get I assume MainViewController:

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

Left Voicing Week Controller. H:

  #import & lt; UIKit / UIKit.h & gt; #import "Main vs Controller H" # Import & lt; Message UI / MessageIiH & GT; #important & lt; Message ii / mfmail combo viewcontroller.h & gt; @ Class MainViewController; @ Interface Left Sharing Controller: UIViewController & lt; MFMailComposeViewControllerDelegate & gt; {Main view controller * Main view controller; NSString * leftWebViewUrl; } @ Property (non-nominal, retained) Main view controller * Main view controller; @property (nontomic, write) NSString * leftWebViewUrl; @end  

LeftSharingViewController.m:

  #import "LeftSharingViewController.h" #import "MainViewController.h" @ implementation LeftSharingViewController @Synthesize mainViewController; @ Synthesize the left side of the verbiage; - (Zero) ViewWill API: (BOOL) Animated {self.leftWebViewUrl = self.mainViewController.leftWebViewString; } #pragma mark - #pragma mark Compose Mail - (minus) displayComposer sheet {MFMailComposeViewController * mailPicker = [[MFMailComposeViewController alloc] init]; MailPicker.mailComposeDelegate = self; [Mailpeak set topic: @ "check this website!"]; [MailPicker setMessageBody: [NSString stringWithFormat: @ "Take a look at this site: The% @", leftWebViewUrl] HTML: YES]; MailPicker.modalPresentationStyle = UIModal Presentation Formats; [Self current model view controller: animated mailpicker: yes]; [Mailpiker release]; }  

Thanks!

Your main view controller , you can always NSString can not be maintained, you are using stringWithString: , which returns an autorelase object.

You should either retain it, or use your accessor (easy) to change your code, which already preserves:

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

"pull" instead of MainViewController > LeftSharingViewController Navigating to> WmsharingWeek Controller to Main View Controller , I can do it another way: in Main View Controller , LeftSharingViewController Before displaying the view of , I set the required property.


Comments