objective c - Sending HTTP GET Requests with NSURLConnection -


i'm new site , decided ask question has been bugging me while. working on app requires calendar gets events posted on website that's going going along it. i'm new using xcode , objective c i've been using ios 7 programming cookbook me questions might have. however, problem having requests, titles says, , can't seem find dealing exact problem.

appdelegate.m

- (bool) application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions{         nsstring *urlasstring = <# place url of web server here #>; //this area problem         urlasstring = [urlasstring stringbyappendingstring:@"?param1=first"]; //along         urlasstring = [urlasstring stringbyappendingstring:@"&param2=second"]; //and         nsurl *url = [nsurl urlwithstring:urlasstring];         nsmutableurlrequest *urlrequest =             [nsmutableurlrequest requestwithurl:url];         [urlrequest settimeoutinterval:30.0f];         [urlrequest sethttpmethod:@"get"];         nsoperationqueue *queue = [[nsoperationqueue alloc] init];         [nsurlconnection          sendasynchronousrequest:urlrequest          queue:queue          completionhandler:^(nsurlresponse *response,                              nsdata *data,                              nserror *error) { if ([data length] >0 && error == nil){ nsstring *html =                  [[nsstring alloc] initwithdata:data                                        encoding:nsutf8stringencoding];                  nslog(@"html = %@", html);              } else if ([data length] == 0 && error == nil){ nslog(@"nothing downloaded."); } else if (error != nil){     nslog(@"error happened = %@", error);          }      }];     self.window = [[uiwindow alloc] initwithframe:                    [[uiscreen mainscreen] bounds]]; self.window.backgroundcolor = [uicolor whitecolor]; [self.window makekeyandvisible]; return yes; 

this code giving me problems. whenever put url i'm testing section warning says "variable 'urlasstring' uninitialized when used within it's own initialization." "receiver in message expression uninitialized value." results in me getting when try run app "error happened = error domain=nsurlerrordomain code=-1000 "bad url" userinfo=0x9626bf0 {nsunderlyingerror=0x962c9d0 "bad url", nslocalizeddescription=bad url}"

when try running code this:

nsstring *urlasstring = @"url here"; 

it works doesn't need to.

what doing wrong? i'm following book telling me keep getting these warnings. appreciated! thanks


Comments

Popular posts from this blog

jQuery Mobile app not scrolling in Firefox -

c++ - How to add Crypto++ library to Qt project -

php array slice every 2th rule -