Hi, i have a problem with the method "[NSStrng stringWithContentOfURL:url]"; all things worked so fine until i change my url from a web address to an ip address with which i got an empty string. Did you have a solution or an idea? Thks
+1
A:
Use a method that returns an error status (e.g. +stringWithContentsOfURL:encoding:error:
) and check the error return.
update: NSCocoaErrorDomain Code=256 is "NSFileReadUnknownError", which means "file read error, reason unknown" (not very helpful). Probably there's something wrong with the URL (misspelled pathname, wrong IP address, etc.)
Numeric IP addresses most definitely are supported in URLs, so that's not the problem.
see also http://stackoverflow.com/questions/1827364/iphone-datawithcontentsofurl-does-not-work-for-some-urls
David Gelhar
2010-10-12 12:40:41
There is no error,i checked and the NSError variable had the number 0,there is no problem with the use of ip address of server from iphone app?on the browser all things were right.
Dingua
2010-10-12 15:35:10
Excuse me the error had the number 256 which is "NSCocoaErrorDomain"
Dingua
2010-10-12 15:41:57
Than you David, but we can't say that the problem is about a misspell because as i said all things are right if we work on a browser.what do you think?
Dingua
2010-10-12 16:21:32
Safari uses the same URL loading code as your application does, so there's no reason a URL would work in Safari on the phone but not in an application. Were you testing using a desktop browser, or Safari on the phone? Are you testing the application in the simulator or on the device?
David Gelhar
2010-10-12 16:30:47
with safari things were right too even on simulator ,for test i use the simulator.
Dingua
2010-10-12 16:49:49
In that case, I don't know: if you can literally copy the URL from your application and paste it into Safari and it works, the only other thing I can think of is some kind of encoding issue. Maybe try NSData instead of NSString?
David Gelhar
2010-10-12 17:00:29
Also with NSData the variable was empty.i think that the problem is with the URL.maybe;)i am hopeless
Dingua
2010-10-12 17:34:27