Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
I was a little absent minded and didn't have the code typed out the same in my .m as I did in my .h. I fixed this to where it would compile and it works. Here is the code I have in my compose sheet to fill out the email body
Code:
// Fill out the email body text
	NSString *emailBody = [NSString stringWithFormat:@"<html><head></head><body>%@</body></html>", currentURL];
	[picker setMessageBody:emailBody isHTML:YES];
When I do that and click to compose email, the email body simply shows (null).
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Again, basic debugging. What is the value of currentURL before you use it in the stringWithFormat:? (It's probably nil.) Think about why that may be. Trace back to where it is set. Is it being assigned as expected? If not, why not? Etc.

Also, since it's a property, you should reference it via the getter you synthesized, i.e. self.currentURL.
 

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
Where in the debugger do I get the value of currentURL?
UPDATE:
Crashing for the night. Been banging my head against the wall trying to figure out why currentURL is coming back as nil. .h has it declared and property. .m has it synthesized. ViewDidLoad of view controller has the request for absolutestring. The webview will load to the predetermined page, but currentURL always shows as nil, and I can't figure out why.

Ran an NSLog. It only got pulled once showing:
Code:
Attaching to process 9544.
2010-08-24 10:14:25.964 Bell Avenue[9544:207] sermons called, currentURL set to (null)
[Switching to process 9544]
 

ianray

macrumors 6502
Jun 22, 2010
452
0
@
The webview will load to the predetermined page, but currentURL always shows as nil, and I can't figure out why.

You've made good progress! -- You now know the failure location.

Code:
[sermons loadRequest:
 [NSURLRequest requestWithURL:
  [NSURL URLWithString:@"http://www.316apps.com/iphonesermons.html"]]];

// sermons.request.URL.absoluteString returns nil
self.currentURL = sermons.request.URL.absoluteString;

Now... to figure out why. It may be:

  1. The "sermons" object is not ready
  2. Bug in iOS
  3. Enemy action

Is this an academic exercise? I only ask because a literal URL was included in the loadRequest...
 

ianray

macrumors 6502
Jun 22, 2010
452
0
@
I'll rephrase the question. Given (the text highlighted in bold),

Code:
[sermons loadRequest:
 [NSURLRequest requestWithURL:
  [NSURL URLWithString:@"[B]http://www.316apps.com/iphonesermons.html[/B]"]]];

then, why do you need (the text highlighted in bold) ?

Code:
self.currentURL = [B]sermons.request.URL.absoluteString[/B];
 

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
I'll rephrase the question. Given (the text highlighted in bold),

Code:
[sermons loadRequest:
 [NSURLRequest requestWithURL:
  [NSURL URLWithString:@"[B]http://www.316apps.com/iphonesermons.html[/B]"]]];

then, why do you need (the text highlighted in bold) ?

Code:
self.currentURL = [B]sermons.request.URL.absoluteString[/B];
I was doing some testing on this and had changed the website from what it actually will be. The website it opens to originally will be http://bacocnews.wordpress.com. The reason I was needing to get currentURL is the idea that someone could read an article in the blog, and then click the email button and have it email the site of the article they had clicked on, instead of the original loading page.
 

ianray

macrumors 6502
Jun 22, 2010
452
0
@
The reason I was needing to get currentURL is the idea that someone could read an article in the blog, and then click the email button and have it email the site of the article they had clicked on, instead of the original loading page.

Sounds like you need to get the URL on demand, as opposed to attempting (and failing) to get it before the UIWebView is ready... :)
 

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
The email button is connected to an IBaction to view the mail composer sheet. Is it still possible to put it in there with that?
 

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
I finally got it to work with the email part! When I got back to my computer I put the self.currentURL line in with the IBAction to pull up the mail composer, and it worked like a charm. Thanks for all the help! If anyone has similar issues and would like to see a snippet of the code used for this just PM me.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.