View Full Version : Problem with NSStrings
alexandergre
Sep 11, 2009, 06:44 AM
This code works correctly. It loads the google.com in UIWebVIew.
NSLog(aBook.title); //output is :Yahoo
NSLog(aBook.author); //output is : http://www.yahoo.com
NSString *path = [NSString stringWithFormat:@"http://www.google.com"];
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.
NSLog(aBook.title); //output is :Yahoo
NSLog(aBook.author); //output is : http://www.yahoo.com
NSString *path = [NSString stringWithFormat:@"%@",aBook.author];
NSURL *url = [NSURL URLWithString:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[myWebView loadRequest:request];
dejo
Sep 11, 2009, 09:57 AM
What exactly is not working? Are you getting any run-time errors?
alexandergre
Sep 16, 2009, 05:05 PM
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.
dejo
Sep 16, 2009, 05:19 PM
If you want I can upload the project.
Might as well. My code test loads Yahoo just fine.
alexandergre
Sep 16, 2009, 05:28 PM
Might as well. My code test loads Yahoo just fine.
http://eskapps.com/XML.zip
the code is in: BookDetailViewController.m
dejo
Sep 16, 2009, 05:33 PM
Thanks. I'll look into it.
Before I do that though, here's a suggestion: the proper way to use NSLog
NSLog(@"%@", aBook.title); //output is :Yahoo
NSLog(@"%@", aBook.author); //output is : http://www.yahoo.com
alexandergre
Sep 16, 2009, 05:34 PM
Thanks. I'll look into it.
Before I do that though, here's a suggestion: the proper way to use NSLog
NSLog(@"%@", aBook.title); //output is :Yahoo
NSLog(@"%@", aBook.author); //output is : http://www.yahoo.com
Thank you man.
I really appreciate it. :P
dejo
Sep 16, 2009, 05:43 PM
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!
alexandergre
Sep 16, 2009, 05:53 PM
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?
dejo
Sep 16, 2009, 05:57 PM
How long have been a iphone developer? other langs?
Been an iPhone developer since July 2008. Other languages? How much time you got? ;) I'll give you the major ones, starting with programming the Commodore PET in 1981: BASIC, 6502 Assembler, C, Nomad (http://en.wikipedia.org/wiki/Nomad_software), PL/SQL, Java.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.