Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON response from localhost in XCode iphone Simulator
    primarykey
    data
    text
    <p>I am trying to receive a JSON response in iPhone simulator using localhost web service.</p> <p>I turned on Web sharing and placed the php file named "readmain.php" in /Library/WebServer/Documents</p> <p>When i write "http://localhost/readmain.php" in Chrome, I see the result displayed perfectly.</p> <p>But when I try to receive the response in my app, an error is received.</p> <p>I am using ASIHTTPRequest</p> <p>Here's the code:</p> <pre><code>NSURL *url = [NSString stringWithFormat:@"%@%@", HJServerAddress, @"readmain.php"]; DLog(@"request URL = %@", [url description]) self.httpRequest = [ASIHTTPRequest requestWithURL:url]; self.httpRequest.delegate = self; [self.httpRequest startAsynchronous]; [self.activityIndicator startAnimating]; </code></pre> <p>Where HJServerAddress is: #define HJServerAddress @"http://localhost/"</p> <p>Whenever the above piece of code executes, I get response from as failed in:</p> <pre><code> - (void)requestFailed:(ASIHTTPRequest *)request { DLog(@"error: %@", [request.error description]) ULog(@"Failed to load data") } </code></pre> <p>In Logs I get:</p> <pre><code>2012-09-24 17:44:06.153 _APPNAME_[1798:f803] -[HJHomeViewController fetchAddsJson] [Line 122] request URL = "http://localhost/readmain.php" 2012-09-24 17:44:46.457 _APPNAME_[1798:f803] -[HJHomeViewController requestFailed:] [Line 478] error: Error Domain=ASIHTTPRequestErrorDomain Code=10 "NSInvalidArgumentException" UserInfo=0x69656e0 {NSLocalizedFailureReason=-[__NSCFString absoluteURL]: unrecognized selector sent to instance 0xb650510, NSUnderlyingError=0x6960460 "The operation couldn’t be completed. (ASIHTTPRequestErrorDomain error 10.)", NSLocalizedDescription=NSInvalidArgumentException} </code></pre> <p>I had also tried to use the IP address of my MAC instead of using "localhost".</p> <p>I tried accessing the file from iOS simulator's Safari and the response was received successfully.</p> <p>I am unable to receive the response in my underdevelopment app. Am I doing something wrong in my code? Or is there something more to be done?</p> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload