views:

130

answers:

2

My app accesses a simple php file on my server that does a simple echo "YES"; for testing purposes. I try to get the contents of the echo into an NSString object as below but my string is ALWAYS returning (null). Whats wrong?

NSString *theString = [NSString stringWithContentsOfURL:aURLThatEchos];
NSLog(@"Value is: %@", theString);



//Outputs: Value is: (null)
+1  A: 

Make sure that the URL is actually a valid, non-nil NSURL object. Make sure that the server is seeing the hit. You could also try using NSURLConnection, ASIHTTPRequest or some other asynchronous method to make the request as this will provide you with more failure and error information.

coneybeare
+1  A: 

Just to make sure, you are aware that when you call stringWithContentsOfURL, the URL must not be a string, but a NSURL object, instanciated with [NSURL URLWithString:@"http://site.com"];?

naixn