Search Results

Search found 244 results on 10 pages for 'nsurlconnection'.

Page 4/10 | < Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >

  • CFNetwork / NSURLConnection leak

    - by JK
    Running instruments on the device, I intermittently incur a memory leak of exactly 3.5 KB in CFNetwork, the responsible frame being "HostLookup_Master::HostLookup...." I have read a number of questions re this issue and have separately tried the following to fix the leak: Included the following in applicationDidFinishLaunching: NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; [NSURLCache setSharedURLCache:sharedCache]; [sharedCache release]; Specified in the urlrequest not to load from the local cache. None of the above worked. My class that instantiates the connections does not leak as its instances are released when data has been downloaded. I have verified this by confirming the the living objects of the class is 0 using Instruments. Any advice on addressing this leak would be greatly appreciated.

    Read the article

  • How to use NSURLDownload

    - by marshluca
    - (IBAction)startDownloadingURL:(id)sender { // create the request NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.apple.com/index.html"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; // create the connection with the request // and start loading the data NSURLDownload *theDownload=[[NSURLDownload alloc] initWithRequest:theRequest delegate:self]; if (!theDownload) { // inform the user that the download could not be made } } when i run the simulator , i got an error: NSURLDownload undeclared ,first use in this fuction. where can i import the library of NSURLDownload.

    Read the article

  • [iphone,twitter] Accessing the Twitter API through a proxy using NSURLConnectionsm, OAuth problem

    - by akaii
    I'm having no problems with sending an update directly via hxxps://api.twitter.com/, but the app (for the Iphone, I'm using NSURLConnections) I'm working is supposed to allow the user to select a preferred proxy (e.g. hxxps://twitter-proxy.appspot.com/api/ or hxxps://nest.onedd.net/api/), and I keep getting a 401 error (Failed to validate oauth signature and token) whenever I try to get an access token via these proxies. Even though I send my POST request to the proxy, I am still using the direct url for the api (https:// api.twitter.com/[rest api path]) in the base string. Despite the 401 error message above, the status code I'm actually getting from connection:didReceiveResponse: is 200, probably because it was able to successfully contact the proxy... Is there anything else that I need to consider when using a proxy to access the API? Should anything in the authorization header change, for example? Or the base string? I can manage to connect via Basic Auth without issue, but support for that will be dropped in a month. On a somewhat unrelated note... What are the possible causes of Twitter's error 403, and how do you distinguish between them? Is the only way to differentiate an error due to exceeding the status update limit for an hour (150 per hour) vs for a day (1000 per day) by checking the string reply returned in the response? Is there any way for me to simulate a status update limit error without going through the motions of actually sending 150/1000 tweets?

    Read the article

  • Asynchronous Request make for-Loop waiting for didFinishLoading

    - by rdesign
    Hey guys, I have a asynchronous url request within a for loop. This loop is called 20 times, each time one parameter of the webaddress is changed. Everytime the didFinishLoading method is called I want to hand over the data of this specific webadress. The problem now is that when I run the for loop, the didFinishLoading method is not called, only at the end. Any suggenstions on how to make the loop wait for complete loading the data for the specific URL? Thanks a lot.

    Read the article

  • Objective-C and NSURL: where am I supposed to declare receivedData?

    - by jthomas
    I have a two classes, a controller called "AppController" and a class called "URLDelegate" that encapsulates the sample NSURL code from Apple's URL Loading System Programming Guide. The guide repeatedly mentions declaring the receivedData instance variable "elsewhere." I assume this means outside of the URLDelagate class, because if I declare it in the URLDelegate class, my controller class can't "see" the data that has been downloaded. I know that data is received, because in my connectionDidFinishLoading function, I have NSLog display the results: NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]); receivedText=[[NSString alloc] initWithData:receivedData encoding: NSASCIIStringEncoding]; NSLog(@"receivedText=%@",receivedText); So I'm a bit stumped with the following questions: Where should I declare receivedData? My controller class? A third class? Can I just declare it like any normal NSMutableData variable? How do I give my URLDelegate class "access" to this variable? E.g., if I declare receivedData in my AppController class, wouldn't I have to instantiate AppController within URLDelegate? But how would this possible if it's the AppController class which is instantiating the URLDelegate class in the first place? Especially with regard to the last question, I feel like I must be overlooking something blindingly obvious and fundamental. If anyone could point me in the right direction, I would really appreciate it. Thank you!

    Read the article

  • Download and Archive Web Pages on the iPhone

    - by Stefan
    Hi, how do I download and archive full web pages (HTML, CSS, JS, images) on the iPhone? I know how to download the single files. But is there any existing approach to get all files (e.g. all included javascripts), which are linked with a particular web page?

    Read the article

  • iPhone SDK: My server doesn't support range header requests, does that mean it's impossible for me t

    - by Jessica
    I am currently developing an iPhone app, in which involves downloads of up to 300 mb. I have been told by my hosting service that my server does not support range header requests. However, when I download a file from my server using a download client, like safari download manager, resume options are available and work. Does this mean that they have a work around for servers that don't support range header requests and that I could possibly implement into my iPhone app? Or are they using a technique too complex to implement into the iPhone. If you know of a technique code samples will be greatly appreciated.

    Read the article

  • [iPhone app] Inserting special char un NSString for URL use

    - by Dough
    Hi, I'm using HTTP connection to share data with my JSON server. I use URLs like "MyServlet?param1=value1" and so on... I'm now facing a problem with one of my servlet (I can't change it because some other views are using it) : The servlet is working with a syntax including those symbols "{" and "}". The exact syntax is {(value1_value2)(value3_value4)(value5_value6)}{(value7_value8)(value9_value10)(value11_value12)}{(value13_value14)(value15_value16)(value17_value18)} Values are integers, the problem is only when I use "{" and "}" my UrlConnection returns an error for bad URL. I use this to instantiate my NSString : NSString *myURL = [NSString stringWithFormat:@"http://somesite.com/Servlet?PARAM={(%@)}"]; How can I code those char in my NSString ? Thanks in advance !

    Read the article

  • How to make an NSURL that contains a | (pipe character)?

    - by aks
    Hi all, I am trying to access google maps' forward geocoding service from my iphone app. When i try to make an NSURL from a string with a pipe in it I just get a nil pointer. NSURL *searchURL = [NSURL URLWithString:@"http://maps.google.com/maps/api/geocode/json?address=6th+and+pine&bounds=37.331689,-122.030731|37.331689,-122.030731&sensor=false"]; I dont see any other way in the google api to send bounds coordinates with out a pipe. Any ideas about how I can do this?

    Read the article

  • previousFailureCount always stays on 0 (zero)

    - by itai alter
    Hello all, First of all, I'd like to thank the good people who helped me around on this site. Thanks. I'm trying to detect a failed authentication attempt in my app... I'm using the didReceiveAuthenticationChallenge method, and the checking if [challenge previousFailureCount] is equal to 0. The problem is that it's always stays on zero, even if the username and password that I send with the credentials are incorrect. I couldn't find any info about this kind of issue, any help will be much appreciated. Thanks!

    Read the article

  • Why do we use networking libraries instead of plain NSURLRequests and NSURLConnection ?

    - by Amogh Talpallikar
    in iOS development, I have often seen people creating a networking module to interact with their APIs. This module generally sits on top of a networking framework like MKNetWorkKit or AFNetWorking. In most of the cases, It's all about sending GET,POST request and parsing the response which is in most cases JSON. What extra practical benefits that these libraries provide that an iOS developer should be leveraging which the plain Cocoa Networking APIs lack ? I can understand RESTKit as one exception where it takes care of the conversion of JSON to native objects and also interfaces with Core Data but what about others ?

    Read the article

  • iphone download several files

    - by Floo
    hi all !  In my app i need to download several plist.  to download a plist i use the NSURLconnection  in my code i use an UIAlertView with a UIActivityIndicator then when the download is finished i add a button to the alert to dismiss it.  To download the plist i use somewhere in my code an NSURL set to the adresse where the plist is, next i set a NSURLRequest with the url cache policy and a timeout interval.  Then i set my NSMutableData to the NSURL connection with a NSURLRequest.  In the delegate didReceiveData: i append data to my mutable data object, in the didFailWithError: i handle error. And finaly in the connectionDidFinishLoading  i serialize my data to a plist so i can write to file my plist, and release my alertview.  My problem is : how can i do if i have sevetal file to download because the connectionDidFinishLoading is called each time my NSURLConnection is finished but i want to release my UiAlert when everything is finished. But when the first plist is downloaded my code in the connectionDidFinishLoading will fire.  here is my code :  in the view did load :  // set the UiAlert in the view did load  NSURL *theUrl = [NSURL URLWithString:@"http://adress.com/plist/myPlist.plist"]; NSURLRequest *theRequest = [NSURLRequest requestWithURL:theUrl cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; self.plistConnection = [[ NSURLConnection alloc] initwithRequest:theRequest delegate:self startImmediatly:YES]; //plistConnection is a NSURLConnection - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {  [incomingPListData appendData:data]; } -(void)connection:(NSURLConnection *)connectionDidFailWithError:(NSError *)error { // handle error here  } -(void)connectionDidFinisloading:(NSURLConnection *) connection {  NSPropertyListFormat format; NSString *serialErrorString;  NSData *plist = [NSPropertyListSerialisation propertyListFromData:incomingPlistData mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&serialErrorString]; if (serialErrorString) {//error} else { // create path and write plist to path} // change message and title of the alert so if i want todownload an another file  where do i put the request the connection and how can i tell the didFinishLoading to fire code when all my file are downloaded.  thanks to all

    Read the article

  • Calculating File size before download

    - by sagar
    Ok ! Coming to the point directly. What I want to do is explained as follows. I have an url of MP3 file. ( for example Sound File ) Now, When user starts application. Download should start & for that I have implemented following methods. -(void)viewDidLoad { [super viewDidLoad]; NSURL *url=[NSURL URLWithString:@"http://xyz.pqr.com/abc.mp3"]; NSURLRequest *req=[NSURLRequest requestWithURL:url cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:120]; NSURLConnection *con=[[NSURLConnection alloc] initWithRequest:req delegate:self startImmediately:YES]; if(con){ myWebData=[[NSMutableData data] retain]; } else { // [MainHandler performSelector:@selector(targetSelector:) withObject:nil]; } } -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ NSLog(@"%@",@"connection established"); [myWebData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSLog(@"%@",@"connection receiving data"); [myWebData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"%@",@"connection failed"); [connection release]; // [AlertViewHandler showAlertWithErrorMessage:@"Sorry, there is no network connection. Please check your network and try again."]; // [self parserDidEndDocument:nil]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; } Now, Above methods work perfectly for downloading. But missing points are as follows. I can not get the exact size which is going to be downloaded. ( means I want to know what is the size of file - which is going to be download )

    Read the article

  • How to update the user profile through tokenid when a particular user logs in using his username and password

    - by Rani
    i have an application in which when the user enters his username and password in the login form , his username and password are submitted to the server database for validation and if he is a valid user a tokenid is generated for him through JSON response and he is allowed to log in.this is the JSON response that i get in the console when a valid user log in through the log in form : {"TokenID":"kaenn43otO","isError":false,"ErrorMessage":"","Result":[{"UserId":"164","FirstName":"Indu","LastName":"nair","Email":"[email protected]","ProfileImage":null,"ThumbnailImage":null,"DeviceInfoId":"22"}],"ErrorCode":900} 2011-06-24 11:56:57.639 Journey[5526:207] this is token id:kaenn43otO so when the same user wants to update his profile by clicking on the update tab using the tokenid So that if he want he can his firstname,lastname,password,email.etc.i i have done the following code to update the user profile using tokenid but it does not work.i get tokenid when the user log in and this tokenid i have to pass to other class: this is my code to update user profile: -(void)sendRequest { //this is the class in which i get the tokenid and i am passing it to this class apicontroller *apitest = [[apicontroller alloc]init]; NSString *tokentest = apitest.tokenapi; NSString *post = [NSString stringWithFormat:@"Token=%@&firstname=%@&lastname=%@&Username=%@&Password=%@&Email=%@",tokentest,txtfirstName.text,txtlast.text,txtUserName.text,txtPassword.text,txtEmail.text]; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; NSLog(@"%@",postLength); NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:@"http://192.168.0.1:96/JourneyMapperAPI?RequestType=Register&Command=SET"]]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:postData]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; if (theConnection) { webData = [[NSMutableData data] retain]; NSLog(@"%@",webData); [theConnection start]; } else { } } -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [webData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [webData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { [connection release]; [webData release]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *loginStatus = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding]; NSLog(@"%@",loginStatus); [loginStatus release]; [connection release]; [webData release]; } -(IBAction)click:(id)sender { [self sendRequest]; } this is my apicontroller.m file in which i am creating login form so that user login and in this page tokenid is generated -(void)sendRequest { UIDevice *device = [UIDevice currentDevice]; NSString *udid = [device uniqueIdentifier]; //NSString *sysname = [device systemName]; NSString *sysver = [device systemVersion]; NSString *model = [device model]; NSLog(@"idis:%@",[device uniqueIdentifier]); NSLog(@"system nameis :%@",[device systemName]); NSLog(@"System version is:%@",[device systemVersion]); NSLog(@"System model is:%@",[device model]); NSLog(@"device orientation is:%d",[device orientation]); NSString *post = [NSString stringWithFormat:@"Loginkey=%@&Password=%@&DeviceCode=%@&Firmware=%@&IMEI=%@",txtUserName.text,txtPassword.text,model,sysver,udid]; NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]]; NSLog(@"%@",postLength); NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:@"http://192.168.0.1:96/JourneyMapperAPI?RequestType=Login"]]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody:postData]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; if (theConnection) { webData = [[NSMutableData data] retain]; NSLog(@"%@",webData); } else { } } //to select username and password from database. -(void)check { //app.journeyList = [[NSMutableArray alloc]init]; [self createEditableCopyOfDatabaseIfNeeded]; NSString *filePath = [self getWritableDBPath]; sqlite3 *database; if(sqlite3_open([filePath UTF8String], &database) == SQLITE_OK) { const char *sqlStatement = "SELECT Username,Password FROM UserInformation where Username=? and Password=?"; sqlite3_stmt *compiledStatement; if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) { sqlite3_bind_text(compiledStatement, 1, [txtUserName.text UTF8String], -1, SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 2, [txtPassword.text UTF8String], -1, SQLITE_TRANSIENT); //NSString *loginname= [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 1)]; // NSString *loginPassword = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 2)]; } if(sqlite3_step(compiledStatement) != SQLITE_ROW ) { NSLog( @"Save Error: %s", sqlite3_errmsg(database) ); UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"UIAlertView" message:@"User is not valid" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; alert = nil; } else { isUserValid = YES; if (isUserValid) { UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"UIAlertView" message:@"Valid User" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; } } sqlite3_finalize(compiledStatement); } sqlite3_close(database); } -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [webData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [webData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { [connection release]; [webData release]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSString *loginStatus = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding]; NSLog(@"%@",loginStatus); //this is to perfrom insert opertion on the userinformation table NSString *json_string = [[NSString alloc] initWithData:webData encoding:NSUTF8StringEncoding]; NSDictionary *result = [json_string JSONValue]; //here i am storing the tokenid tokenapi = [result objectForKey:@"TokenID"]; NSLog(@"this is token id:%@",tokenapi); // BOOL errortest = [[result objectForKey:@"isError"] boolValue]; if(errortest == FALSE) { values = [result objectForKey:@"Result"]; NSLog(@"Valid User"); } else { NSLog(@"Invalid User"); } NSMutableArray *results = [[NSMutableArray alloc] init]; for (int index = 0; index<[values count]; index++) { NSMutableDictionary * value = [values objectAtIndex:index]; Result * result = [[Result alloc] init]; //through this i get the userid result.UserID = [value objectForKey:@"UserId"]; result.FirstName = [value objectForKey:@"FirstName"]; result.Username =[value objectForKey:@"Username"]; result.Email =[value objectForKey:@"Email"]; result.ProfileImage =[value objectForKey:@"ProfileImage"]; result.ThumbnailImage =[value objectForKey:@"ThumbnailImage"]; result.DeviceInfoId =[value objectForKey:@"DeviceInfoId"]; NSLog(@"%@",result.UserID); [results addObject:result]; [result release]; } for (int index = 0; index<[results count]; index++) { Result * result = [results objectAtIndex:index]; //save the object variables to database here [self createEditableCopyOfDatabaseIfNeeded]; NSString *filePath = [self getWritableDBPath]; sqlite3 *database; if(sqlite3_open([filePath UTF8String], &database) == SQLITE_OK) { const char *sqlStatement = "insert into UserInformation(UserID,DeviceId,Username,Password,FirstName,Email) VALUES (?,?,?,?,?,?)"; sqlite3_stmt *compiledStatement; if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) { //sqlite3_bind_text( compiledStatement, 1, [journeyid UTF8String],-1,SQLITE_TRANSIENT); sqlite3_bind_text( compiledStatement, 1, [result.UserID UTF8String],-1,SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 2, [result.DeviceInfoId UTF8String],-1,SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 3, [txtUserName.text UTF8String],-1,SQLITE_TRANSIENT); sqlite3_bind_text(compiledStatement, 4, [txtPassword.text UTF8String],-1,SQLITE_TRANSIENT); sqlite3_bind_text (compiledStatement, 5, [result.FirstName UTF8String],-1,SQLITE_TRANSIENT); sqlite3_bind_text (compiledStatement, 6, [result.Email UTF8String],-1,SQLITE_TRANSIENT); } if(sqlite3_step(compiledStatement) != SQLITE_DONE ) { NSLog( @"Save Error: %s", sqlite3_errmsg(database) ); } else { UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"UIAlertView" message:@"Record added" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; alert = nil; } sqlite3_finalize(compiledStatement); } sqlite3_close(database); } [loginStatus release]; [connection release]; [webData release]; } -(IBAction)click:(id)sender { [self sendRequest]; //this is to select username and password from database. [self check]; } for a particular user who logs in only his profile must be update by using tokenid and userid.Please help me in solving this problem.Thanks

    Read the article

  • UIImage - should be loaded with [UIImage imageNamed:@""] or not ?

    - by sagar
    Hello ! every one. I am having number of images with in my application. ( images more than 50 - approximately & it can extend according to client's need ) Each image are very large round about - 1024 x 768 & 150 dpi Now, I have to add all this images in a scroll view & display it. Ok, My question is as follows. According to me there are two options of loading large images imageNamed:@"" load asynchronously when viewDidLoad Called. Which is more preferable ? imgModel.image=[UIImage imageNamed:[dMain valueForKey:@"imgVal"]]; or like this. NSURL *ur=[[NSURL alloc] initFileURLWithPath:[[NSBundle mainBundle] pathForResource:lblModelName.text ofType:@"png"] isDirectory:NO]; NSURLRequest *req=[NSURLRequest requestWithURL:ur cachePolicy:NSURLCacheStorageNotAllowed timeoutInterval:40]; [ur release]; NSURLConnection *con=[[NSURLConnection alloc] initWithRequest:req delegate:self]; if(con){ myWebData=[[NSMutableData data] retain]; } else { } -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [myWebData setLength: 0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [myWebData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { [connection release]; } -(void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"ImageView Ref From - %@",imgV); // my image view & set image imgV.image=[UIImage imageWithData:myWebData]; [connection release]; connection=nil; }

    Read the article

  • Is it possible to reset NSURLConnection after providing credentials?

    - by John
    I am calling a REST service that requires basic auth and I respond to the didReceiveAuthenticationChallenge delegate OK NSURLCredential *credential = [[NSURLCredential alloc] initWithUser:self.user password:self.password persistence:NSURLCredentialPersistenceForSession]; [[challenge sender] useCredential:credential forAuthenticationChallenge:challenge]; [credential release]; The Credentials are valid for the Session but I would like for my App to be able to switch between servers and therefore need to "reset" the Session so it asks again for a challenge. I can of course try the option of not storing the credentials for the Session and supply them for each call but this does not seem like a good idea. Any ideas would be appreciated!

    Read the article

  • How to call JSON asynchronous in xcode/ iphone develope

    - by Frames84
    I'm using the JSON framework hosting on Google. What and it's a news app that loads JSON feeds, when app goes off to load the feed I want to display the UIActivityIndicatorView but I've found my JSON Access code is not being called asynchronous which is locking the user interface. I have highlighted the function in the code and can't figuree out without breaking how to change the code. #import "JSON DataAccess Wrapper.h" #import "JSON.h" @implementation JSON_DataAccess_Wrapper @synthesize dataItemList; ////////////////////////////////////////////// /* START FEED CONNECTION/ HANDLE METHODS */ ////////////////////////////////////////////// - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [responseData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [responseData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { //label.text = [NSString stringWithFormat:@"Connection failed: %@", [error description]]; } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; } - (NSString *)stringWithUrl:(NSURL *)url { NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30]; NSData *urlData; NSURLResponse *response = nil; NSError *error = nil; /* HOW TO MAKE THE CALL BELOW ASYNCHRONOUS */ urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error]; return [[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding]; } -(id) objectWithUrl:(NSURL *)url { SBJSON *jsonParser = [SBJSON new]; NSString *jsonString = [self stringWithUrl:url]; return [jsonParser objectWithString:jsonString error:NULL]; } - (NSMutableArray *) downloadJSONFeed { id response = [self objectWithUrl:[NSURL URLWithString:@"http://www.mysite.co.uk/index2.php?option=JSON"]]; NSMutableArray *feed = (NSMutableArray *) response; return feed; }

    Read the article

  • populate UITableView from json

    - by mcgrailm
    Hello all working on my building my first iDevice app and I am trying to populate a UITableView with data from json result I can get it to load from plist array no propblem and I can even see my json the problem I'm having is that the UITableView never gets to see the json results please bare with me as this is first time with obj-c or anything like it in my .h file @interface TableViewViewController : UIViewController <UITableViewDataSource, UITableViewDelegate> { NSArray *exercises; NSMutableData *responseData; } in my .m file - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return exercises.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //create a cell UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; // fill it with contnets cell.textLabel.text = [exercises objectAtIndex:indexPath.row]; // return it return cell; } // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { responseData = [[NSMutableData data] retain]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://url_to_json"]]; [[NSURLConnection alloc] initWithRequest:request delegate:self ]; // load from plist //NSString *myfile = [[NSBundle mainBundle] pathForResource:@"exercise" ofType:@"plist"]; //exercises = [[NSArray alloc] initWithContentsOfFile:myfile]; [super viewDidLoad]; } - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { [responseData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [responseData appendData:data]; } - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { NSLog(@"Connection failed: %@", [error description]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; [responseData release]; NSDictionary *dictionary = [responseString JSONValue]; NSArray *response = [dictionary objectForKey:@"response"]; exercises = [[NSArray alloc] initWithArray:response]; }

    Read the article

  • Handling credit cards and IOS

    - by Susan Jackie
    I am using NSUrlConnection asyncronous request to transmit credit card information to a secure third party server. I do the following: I get the credit card number, cvv, etc from the uitextfields. Encode the credit card information into a json format. Set as httpd body of the nsurlconnection request as follows: NSURL * url = [[NSURL URLWithString: "https://www.example.com"]; NSMutableURLRequest * request = [[NSMutableURLRequest alloc] initWithURL: url]; [request setHTTPMethod: @"POST"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setHTTPBody: [NSJSONSerialization dataWithJSONObject: params options: kNilOptions error: &parseError]]; Send this information via asynchronous request to a secure third party server: [NSURLConnection sendAsynchronousRequest:request queue: queue completionHandler:^(NSURLResponse *response, NSData *data, NSError * requestError) { What should I be considering to send user credit card information to a third party server using nsurlconnection asynchronous request?

    Read the article

  • Send parameters to a web service.

    - by Alejandra Meraz
    Before I start: I'm programming for Iphone, using objective C. I have already implemented a call to a web service function using NSURLRequest and NSURLConnection. The function then returns a XML with the info I need. The code is as follows: NSURL *url = [NSURL URLWithString:@"http://myWebService/function"]; NSMutableURLRequest theRequest = [[NSMutableURLRequest alloc] initWithURL:url]; NSURLConnection theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; i also implemented the methods didRecieveResponse didRecieveAuthenticationChallenge didRecievedData didFailWithError connectionDidFinishLoading. And it works perfectly. Now I need to send 2 parameters to the function: "location" and "module". I tried using the following modification: NSMutableURLRequest theRequest = [[NSMutableURLRequest alloc] initWithURL:url]; [theRequest setValue:@"USA" forHTTPHeaderField:@"location"]; [theRequest setValue:@"DEVELOPMENT" forHTTPHeaderField:@"module"]; NSURLConnection theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; But it doesn't seem to work. I'm doing something wrong? is there a way to know if I'm using the wrong names for the parameters (as maybe it is "Location" or "LOCATION" or it doesn't matter?)? or a way to know which parameters is the function waiting for... Extra info: I don't have access to the source of the web service so I can't modify it. But I can access the WSDL. The person who made the function say is all there... but I can't make any sense of it .< Any help would be appreciated. :)

    Read the article

  • iphone tableview & webservice

    - by Anonymous
    Hi, I have a tableview, when the user selects a row i call a webservice depending on which row is selected. my problem is i can connect to the webservice but i dont get any response from the webservice. I used soap client to test if webservice is working correctly or not. //rootviewcontroller.m - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {.... //call to webservice [self connectToWebService]; } On debugging i found that my code does not go to any of the following methods -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *) response{} -(void) connection:(NSURLConnection *) connection didReceiveData:(NSData *) data {} -(void) connection:(NSURLConnection *) connection didFailWithError:(NSError *) error{} -(void) connectionDidFinishLoading:(NSURLConnection *) connection {} any suggestions where am i going wrong??? thanks

    Read the article

  • iphone app: delegate not responding

    - by Fiona
    Hi guys.. So i'm very new to this iphone development stuff.... and i'm stuck. I'm building an app that connects to the twitter api. However when the connectionDidFinishLoading method gets called, it doesn't seem to recognise the delegate. Here's the source code of the request class: import "OnePageRequest.h" @implementation OnePageRequest @synthesize username; @synthesize password; @synthesize receivedData; @synthesize delegate; @synthesize callback; @synthesize errorCallBack; @synthesize contactsArray; -(void)friends_timeline:(id)requestDelegate requestSelector:(SEL)requestSelector{ //set the delegate and selector self.delegate = requestDelegate; self.callback = requestSelector; //Set up the URL of the request to send to twitter!! NSURL *url = [NSURL URLWithString:@"http://twitter.com/statuses/friends_timeline.xml"]; [self request:url]; } -(void)request:(NSURL *) url{ theRequest = [[NSMutableURLRequest alloc] initWithURL:url]; theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection){ //Create the MSMutableData that will hold the received data. //receivedData is declared as a method instance elsewhere receivedData=[[NSMutableData data] retain]; }else{ //errorMessage.text = @"Error connecting to twitter!!"; } } -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge{ if ([challenge previousFailureCount] == 0){ NSLog(@"username: %@ ",[self username]); NSLog(@"password: %@ ",[self password]); NSURLCredential *newCredential = [NSURLCredential credentialWithUser:[self username] password:[self password] persistence:NSURLCredentialPersistenceNone]; [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge]; } else { [[challenge sender] cancelAuthenticationChallenge:challenge]; NSLog(@"Invalid Username or password!"); } } -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response{ [receivedData setLength:0]; } -(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{ [receivedData appendData:data]; } -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error{ [theConnection release]; [receivedData release]; [theRequest release]; NSLog(@"Connection failed. Error: %@ %@", [error localizedDescription], [[error userInfo] objectForKey:NSErrorFailingURLStringKey]); if(errorCallBack){ [delegate performSelector:errorCallBack withObject:error]; } } -(void)connectionDidFinishLoading:(NSURLConnection *)connection{ if (delegate && callback){ if([delegate respondsToSelector:[self callback]]){ [delegate performSelector:[self callback] withObject:receivedData]; }else{ NSLog(@"No response from delegate!"); } } [theConnection release]; [theRequest release]; [receivedData release]; } Here's the .h: @interface OnePageRequest : NSObject { NSString *username; NSString *password; NSMutableData *receivedData; NSURLRequest *theRequest; NSURLConnection *theConnection; id delegate; SEL callback; SEL errorCallBack; NSMutableArray *contactsArray; } @property (nonatomic,retain) NSString *username; @property (nonatomic,retain) NSString *password; @property (nonatomic,retain) NSMutableData *receivedData; @property (nonatomic,retain) id delegate; @property (nonatomic) SEL callback; @property (nonatomic) SEL errorCallBack; @property (nonatomic,retain) NSMutableArray *contactsArray; -(void)friends_timeline:(id)requestDelegate requestSelector:(SEL)requestSelector; -(void)request:(NSURL *) url; @end In the method: connectionDidFinishLoading, the following never gets executed: [delegate performSelector:[self callback] withObject:receivedData]; Instead I get the message: "No response from delegate" Anyone see what I'm doing wrong?! or what might be causing the problem? Regards, Fiona

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10  | Next Page >