nsurlconnection

How can i upload file and other parameter using NSURLConnection

荒凉一梦 提交于 2019-12-01 14:19:29
I am using NSURLConnection to send same data ( NSString ) to the server and i would like to add with them an image or a file so what's the value of the content type? Encoding - (NSData *)encodingData:(NSMutableDictionary *)dictionary { NSMutableArray *arrayPosts = [[NSMutableArray alloc] init]; [dictionary enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { NSString *encodedKey = [key stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *encodedValue = [obj stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [arrayPosts addObject:[NSString

Returning data from data-grabbing class from web?

吃可爱长大的小学妹 提交于 2019-12-01 12:55:18
I'm trying to create a class which will let me get requested data from a web service. I'm stuck on how to return the values. // FooClass.m // DataGrabber is the class which is supposed to get values dataGrabber = [[DataGrabber alloc] init]; xmlString = [dataGrabber getData:[NSDictionary dictionaryWithObjectsAndKeys:@"news", @"instruction", @"sport", @"section", nil]]; In this example, it's supposed to get the sports news. The problem is that the DataGrabber gets the data asynchronously and ends up hopping from several NSURLConnection delegate methods. How do know in FooClass when data has been

didReceiveData is not getting all data

核能气质少年 提交于 2019-12-01 12:39:57
I am trying to download a JSON with NSURLConnection, but unless I force the app to pause some seconds the data I get isn't complete. It is always around 2600 bytes and my response should be around 70000. Any clue why is this happening? Thank You - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { _responseData = [[NSMutableData alloc] init]; //sleep(10); } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [_responseData appendData:data]; [self getDataJSON: _responseData]; } didReceiveData is called a lot of times, while

How can I wait for a NSURLConnection delegate to finish before executing the next statement?

蓝咒 提交于 2019-12-01 12:04:43
This has been a hard one to search. I found a similar question, iOS 5 Wait for delegate to finish before populating a table? , but the accepted answer was 'Refresh the table view,' and that does not help me. The other results I found tended to be in c#. I have an app that streams from iPhone to Wowza servers. When the user hits record, I generate a unique device id, then send it to a PHP script on the server that returns a JSON document with configuration settings (which includes the rtmp dump link). The problem is, the delegate methods are asynchronous, but I need to get the config settings

NSURLConnection Download multiple images

早过忘川 提交于 2019-12-01 11:12:42
I am trying to download multiple images from a URL stored in an XML feed. Getting the image urls from the XML is working correctly. However, the NSURLConnection is creating empty files, but the data is received as noted in NSLog. In connectionDidFinishLoading:(NSURLConnection *)connection , the data and correct bytes are received, the problem is how do I make the receivedData write to the correct file. Semi-working code: -(void)parsingComplete:(XMLDataSource*)theParser { /* iterate through the Categories and create the sub-directory if it does not exist */ for (int i = 0; i < [categories count

didReceiveData is not getting all data

…衆ロ難τιáo~ 提交于 2019-12-01 11:02:50
问题 I am trying to download a JSON with NSURLConnection, but unless I force the app to pause some seconds the data I get isn't complete. It is always around 2600 bytes and my response should be around 70000. Any clue why is this happening? Thank You - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { _responseData = [[NSMutableData alloc] init]; //sleep(10); } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { [

What's wrong on following URLConnection?

隐身守侯 提交于 2019-12-01 10:28:35
See also: Objective-C Asynchronous Web Request with Cookies I spent a day writing this code and can anyone tell me what is wrong here? WSHelper is inherited from NSObject, I even tried NSDocument and NSObjectController and everything.. -(void) loadUrl: (NSString*) urlStr{ url = [[NSURL alloc] initWithString:urlStr]; request = [NSURLRequest requestWithURL:url cachePolicy: NSURLRequestReloadIgnoringCacheData timeoutInterval: 60.0]; connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES]; if(connection) { receivedData = [[NSMutableData data] retain]; //

How can i upload file and other parameter using NSURLConnection

徘徊边缘 提交于 2019-12-01 10:13:19
问题 I am using NSURLConnection to send same data ( NSString ) to the server and i would like to add with them an image or a file so what's the value of the content type? Encoding - (NSData *)encodingData:(NSMutableDictionary *)dictionary { NSMutableArray *arrayPosts = [[NSMutableArray alloc] init]; [dictionary enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { NSString *encodedKey = [key stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *encodedValue = [obj

Mutable NSHTTPURLResponse or NSURLResponse

99封情书 提交于 2019-12-01 09:17:19
I need to modify response headers in an NSURLResponse. Is this possible? Colin Barrett I was just talking about this with a friend. My suggestion would be to write a subclass of NSURLResponse. Something along these lines: @interface MyHTTPURLResponse : NSURLResponse { NSDictionary *myDict; } - (void)setAllHeaderFields:(NSDictionary *)dictionary; @end @implementation MyHTTPURLResponse - (NSDictionary *)allHeaderFields { return myDict ?: [super allHeaderFields]; } - (void)setAllHeaderFields:(NSDictionary *)dict { if (myDict != dict) { [myDict release]; myDict = [dict retain]; } } @end If you're

What's wrong on following URLConnection?

人盡茶涼 提交于 2019-12-01 08:37:23
问题 See also: Objective-C Asynchronous Web Request with Cookies I spent a day writing this code and can anyone tell me what is wrong here? WSHelper is inherited from NSObject, I even tried NSDocument and NSObjectController and everything.. -(void) loadUrl: (NSString*) urlStr{ url = [[NSURL alloc] initWithString:urlStr]; request = [NSURLRequest requestWithURL:url cachePolicy: NSURLRequestReloadIgnoringCacheData timeoutInterval: 60.0]; connection = [[NSURLConnection alloc] initWithRequest:request