Note that there are some explanatory texts on larger screens.

plurals
  1. POissue with returned json array
    primarykey
    data
    text
    <p>I have two questions:</p> <p>1.I want to load information from json in my app, right now 'NSLog(@"Array: %@", self.news);' doesn't show anything but if I put it in '(void)connectionDidFinishLoading:(NSURLConnection *)connection' it works, can you tell me why?</p> <pre><code>//making request query string NSString *requestUrl = [NSString stringWithFormat:@"%@jsons/json.php?go=product_info&amp;latitude=%g&amp;longitude=%g&amp;identifire=%@&amp;pid=%ld&amp;externalIPAddress=%@&amp;localIPAddress=%@", BASE_URL, coordinate.latitude, coordinate.longitude, uniqueIdentifier, (long)self.productId, [self getIPAddress], [self getLocalIPAddress] ]; NSURL *url=[NSURL URLWithString:requestUrl]; NSURLRequest *request= [NSURLRequest requestWithURL:url]; NSURLConnection *c=[[NSURLConnection alloc] initWithRequest:request delegate:self]; NSLog(@"Array: %@", self.news); } //========================= -(void)connection: (NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ self.jsonData= [[NSMutableData alloc] init]; } -(void)connection: (NSURLConnection *)connection didReceiveData:(NSData *)theData{ [self.jsonData appendData:theData]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection{ self.news=[NSJSONSerialization JSONObjectWithData:self.jsonData options:nil error:nil]; } -(void)connection: (NSURLConnection *)connection didFailWithError:(NSError *)error{ UIAlertView *errorView=[[UIAlertView alloc] initWithTitle:@"Error" message:@"download could not be compelete" delegate:nil cancelButtonTitle:@"Dissmiss" otherButtonTitles:nil, nil]; [errorView show]; } </code></pre> <p>2.I always have warning 'incompatible pointer to integer conversion sending '*void' to parameter of type 'NSJSONreading...'' for this line of code 'self.news=[NSJSONSerialization JSONObjectWithData:self.jsonData options:nil error:nil];'</p> <p>self.news is an array I changed it to dictionary but I've got same warning message.</p>
    singulars
    1. This table or related slice is empty.
    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