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

alexandergre

macrumors member
Original poster
Jul 28, 2009
58
0
This code works correctly. It loads the google.com in UIWebVIew.
Code:
		NSLog(aBook.title);  //output is :Yahoo
		NSLog(aBook.author); //output is : http://www.yahoo.com
			
		NSString *path = [[B]NSString stringWithFormat:@"http://www.google.com"[/B]];
		NSURL *url = [NSURL URLWithString:path];
		NSURLRequest *request = [NSURLRequest requestWithURL:url];
		[myWebView loadRequest:request];


But not this one. How can I fix this. I dont understand.
Code:
		NSLog(aBook.title);  //output is :Yahoo
		NSLog(aBook.author); //output is : http://www.yahoo.com
			
		NSString *path = [[B]NSString stringWithFormat:@"%@",aBook.author[/B]];
		NSURL *url = [NSURL URLWithString:path];
		NSURLRequest *request = [NSURLRequest requestWithURL:url];
		[myWebView loadRequest:request];
 
What exactly is not working? Are you getting any run-time errors?

sorry if I reply so late. Been away.
The URL wont load in the UIwebview.
NO run time errors. If you want I can upload the project. Its really strange.
 
Thanks. I'll look into it.

Before I do that though, here's a suggestion: the proper way to use NSLog
Code:
NSLog(@"%@", aBook.title);  //output is :Yahoo
NSLog(@"%@", aBook.author); //output is : http://www.yahoo.com
 
Thanks. I'll look into it.

Before I do that though, here's a suggestion: the proper way to use NSLog
Code:
NSLog(@"%@", aBook.title);  //output is :Yahoo
NSLog(@"%@", aBook.author); //output is : http://www.yahoo.com

Thank you man.
I really appreciate it. :p
 
Here's your problem:
aBook.author doesn't contain "http://www.yahoo.com". It contains "/nhttp:www.yahoo.com".

How did I figure this out? Simple. I put a breakpoint at the line that assigns path and used the Debugger window to tell me what path was getting assigned. So, the lesson is: use breakpoints and use the Debugger!
 
Here's your problem:
aBook.author doesn't contain "http://www.yahoo.com". It contains "/nhttp:www.yahoo.com".

How did I figure this out? Simple. I put a breakpoint at the line that assigns path and used the Debugger window to tell me what path was getting assigned. So, the lesson is: use breakpoints and use the Debugger!

WOW man that was quick.
Thank you very very much. YOu are great. How long have been a iphone developer? other langs?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.