Search Results

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

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

  • Objective-c for the iphone: Mystery memory leak

    - by user200341
    My application seems to have 4 memory leaks (on the device, running instruments). The memory leaks seems to come from this code: NSURL *url = [self getUrl:destination]; [destination release]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url]; [url release]; [request setHTTPMethod:@"GET"]; [request addValue:@"application/json" forHTTPHeaderField:@"content-type"]; NSURLConnection *connection = [[NSURLConnection alloc]initWithRequest:request delegate:self]; [request release]; [connection release]; I am releasing all my objects as far as I can see but it's still showing this as the source of the 4 memory leaks. This is on the Device running 3.1.3 Is it acceptable to have a few memory leaks in your app or do they all have to go?

    Read the article

  • NSURLSession and amazon S3 uploads

    - by George Green
    I have an app which is currently uploading images to amazon S3. I have been trying to switch it from using NSURLConnection to NSURLSession so that the uploads can continue while the app is in the background! I seem to be hitting a bit of an issue. The NSURLRequest is created and passed to the NSURLSession but amazon sends back a 403 - forbidden response, if I pass the same request to a NSURLConnection it uploads the file perfectly. Here is the code that creates the response: NSString *requestURLString = [NSString stringWithFormat:@"http://%@.%@/%@/%@", BUCKET_NAME, AWS_HOST, DIRECTORY_NAME, filename]; NSURL *requestURL = [NSURL URLWithString:requestURLString]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:60.0]; // Configure request [request setHTTPMethod:@"PUT"]; [request setValue:[NSString stringWithFormat:@"%@.%@", BUCKET_NAME, AWS_HOST] forHTTPHeaderField:@"Host"]; [request setValue:[self formattedDateString] forHTTPHeaderField:@"Date"]; [request setValue:@"public-read" forHTTPHeaderField:@"x-amz-acl"]; [request setHTTPBody:imageData]; And then this signs the response (I think this came from another SO answer): NSString *contentMd5 = [request valueForHTTPHeaderField:@"Content-MD5"]; NSString *contentType = [request valueForHTTPHeaderField:@"Content-Type"]; NSString *timestamp = [request valueForHTTPHeaderField:@"Date"]; if (nil == contentMd5) contentMd5 = @""; if (nil == contentType) contentType = @""; NSMutableString *canonicalizedAmzHeaders = [NSMutableString string]; NSArray *sortedHeaders = [[[request allHTTPHeaderFields] allKeys] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; for (id key in sortedHeaders) { NSString *keyName = [(NSString *)key lowercaseString]; if ([keyName hasPrefix:@"x-amz-"]){ [canonicalizedAmzHeaders appendFormat:@"%@:%@\n", keyName, [request valueForHTTPHeaderField:(NSString *)key]]; } } NSString *bucket = @""; NSString *path = request.URL.path; NSString *query = request.URL.query; NSString *host = [request valueForHTTPHeaderField:@"Host"]; if (![host isEqualToString:@"s3.amazonaws.com"]) { bucket = [host substringToIndex:[host rangeOfString:@".s3.amazonaws.com"].location]; } NSString* canonicalizedResource; if (nil == path || path.length < 1) { if ( nil == bucket || bucket.length < 1 ) { canonicalizedResource = @"/"; } else { canonicalizedResource = [NSString stringWithFormat:@"/%@/", bucket]; } } else { canonicalizedResource = [NSString stringWithFormat:@"/%@%@", bucket, path]; } if (query != nil && [query length] > 0) { canonicalizedResource = [canonicalizedResource stringByAppendingFormat:@"?%@", query]; } NSString* stringToSign = [NSString stringWithFormat:@"%@\n%@\n%@\n%@\n%@%@", [request HTTPMethod], contentMd5, contentType, timestamp, canonicalizedAmzHeaders, canonicalizedResource]; NSString *signature = [self signatureForString:stringToSign]; [request setValue:[NSString stringWithFormat:@"AWS %@:%@", self.S3AccessKey, signature] forHTTPHeaderField:@"Authorization"]; Then if I use this line of code: [NSURLConnection connectionWithRequest:request delegate:self]; It works and uploads the file, but if I use: NSURLSessionUploadTask *task = [self.session uploadTaskWithRequest:request fromFile:[NSURL fileURLWithPath:filePath]]; [task resume]; I get the forbidden error..!? Has anyone tried uploading to S3 with this and hit similar issues? I wonder if it is to do with the way the session pauses and resumes uploads, or it is doing something funny to the request..? One possible solution would be to upload the file to an interim server that I control and have that forward it to S3 when it is complete... but this is clearly not an ideal solution! Any help is much appreciated!! Thanks!

    Read the article

  • Post data to aspx page from iphone application

    - by Dipen
    Hi, I am developing a application. In which i am posting a image to .aspx page.The HTML for the page is as below. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>"> <html xmlns="http://www.w3.org/1999/xhtml>"> <head><title> Untitled Page </title><link href="App_Themes/XXX/XXX.css" type="text/css" rel="stylesheet" /></head> <body> <form name="form1" method="post" action="Default16.aspx" id="form1" enctype="multipart/form-data"> <div> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTQwMjY2MDA0Mw9kFgICAw8WAh4HZW5jdHlwZQUTbXVsdGlwYXJ0L2Zvcm0tZGF0YWRktr+hG1VVXZsO01PCyj61d6Ulqy8=" /> </div> <div> <div style="float:left;margin:10px"> <input type="file" name="fuImage" id="fuImage" /> </div> <div style="float:right"> <input type="submit" name="btnPost" value="Post Image" id="btnPost" /> </div> </div> </form> </body> </html> Now i am sending a request from my application then i am getting " Error Domain=kCFErrorDomainCFNetwork Code=303 UserInfo=0xf541c0 "Operation could not be completed. (kCFErrorDomainCFNetwork error 303.)"" I have tried using SynchronousRequest and aSynchronousRequest but both are not working. I have also used apple sample code. Here is the code for iPhone app UIImage *image=[UIImage imageNamed:@"photo2.jpg"]; NSData *imageData = UIImageJPEGRepresentation(image, 90); NSString *urlString = @"http://XXXXXXXX.com/Post.aspx"; NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; NSString *boundary = [NSString stringWithString:@"----WebKitFormBoundarylU9pAl5wPrF+Tk52"]; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", boundary]; [request addValue:contentType forHTTPHeaderField:@"Content-Type"]; NSMutableData *body = [NSMutableData data]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"fuimage\"; filename=\"asd.jpg\"\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[[NSString stringWithString:@"Content-Type: image/jpeg\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [body appendData:[NSData dataWithData:imageData]]; [body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary] dataUsingEncoding:NSUTF8StringEncoding]]; [request setHTTPBody:body]; // NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil]; // NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding]; // NSLog(returnString); NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; if( theConnection ) { webData = [[NSMutableData data] retain]; } else { NSLog(@"theConnection is NULL"); } Thanks in Advance.

    Read the article

  • Async networking + threading problem

    - by randallmeadows
    I kick off a network request, assuming no login credentials are required to talk to the destination server. If they are required, then I get an authentication challenge, at which point I display a view requesting said credentials from the user. When they are supplied, I restart the network request, using those credentials. That's all fine and dandy, as long as I only do one request at a time. But I'm not, typically. When both requests are kicked off, I get the first challenge, and present the prompt (using -presentModalViewController:). Then the 2nd challenge comes in. And I crash when it tries to display the 2nd prompt. I have the bulk of this wrapped in an @synchronized() block, but this has no effect because these delegate methods are all being called on the same (main) thread. The docs say the delegate methods are called on the same thread in which the connection was started. OK, no problem; I'll just write a method that I run on a background thread using -performSelectorInBackground: NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:NO]; [connections addObject:connection]; [self performSelectorInBackground:@selector(startConnection:) withObject:connection]; [connection release]; - (void)startConnection:(NSURLConnection *)connection { NSAutoreleasePool *pool = [NSAutoreleasePool new]; [connection scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; [connection start]; [pool drain]; } which should put every network request, and its callbacks, on its own thread, and then my @synchronized() blocks will take effect. The docs for -initWithRequest:... state "Messages to the delegate will be sent on the thread that calls this method. By default, for the connection to work correctly the calling thread’s run loop must be operating in the default run loop mode." Ok, I'm doing that. They also state "If you pass NO [for startImmediately], you must schedule the connection in a run loop before starting it." OK, I'm doing that, too. Furthermore, the docs for NSRunLoop state "Each NSThread object, including the application’s main thread, has an NSRunLoop object automatically created for it as needed. If you need to access the current thread’s run loop, you do so with the class method currentRunLoop." I'm assuming this applies to the background thread created by the call -performSelectorInBackground... (which does appear to be the case, when I execute 'po [NSClassFromString(@"NSRunLoop") currentRunLoop]' in the -startConnection: method). The -startConnection: method is indeed being called. But after kicking off the connection, I now never get any callbacks on it. None of the -connectionDid… delegate methods. (I even tried explicitly starting the thread's run loop, but that made no difference; I've used threads like this before, and I've never had to start the run loop manually before--but I'm now grasping at straws...) I think I've come up with a workaround such that I only handle one request at a time, but it's kludgy and I'd like to do this the Right Way. But, what am I missing here? Thanks! randy

    Read the article

  • Application shows low memory warning and crashes while loading images?

    - by Bhoomi
    I am using following code for loading images from server using following code.When i scroll UITableView application crashes. AsynchrohousImageView class .m file - (void)dealloc { [connection cancel]; //in case the URL is still downloading [connection release]; [data release]; [_imageView release]; [_activityIndicator release]; [super dealloc]; } - (void)loadImageFromURL:(NSURL*)url defaultImageName:(NSString *)defaultImageName showDefaultImage:(BOOL)defaultImageIsShown showActivityIndicator:(BOOL)activityIndicatorIsShown activityIndicatorRect:(CGRect)activityIndicatorRect activityIndicatorStyle:(UIActivityIndicatorViewStyle)activityIndicatorStyle { if (connection!=nil) { [connection release]; } if (data!=nil) { [data release]; } if ([[self subviews] count]>0) { [[[self subviews] objectAtIndex:0] removeFromSuperview]; // } if (defaultImageIsShown) { self.imageView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:defaultImageName]] autorelease]; } else { self.imageView = [[[UIImageView alloc] init] autorelease]; } [self addSubview:_imageView]; _imageView.frame = self.bounds; [_imageView setNeedsLayout]; [self setNeedsLayout]; if (activityIndicatorIsShown) { self.activityIndicator = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:activityIndicatorStyle] autorelease]; [self addSubview:_activityIndicator]; _activityIndicator.frame = activityIndicatorRect; _activityIndicator.center = CGPointMake(_imageView.frame.size.width/2, _imageView.frame.size.height/2); [_activityIndicator setHidesWhenStopped:YES]; [_activityIndicator startAnimating]; } NSURLRequest* request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; connection = [[NSURLConnection alloc] initWithRequest:request delegate:self]; } - (void)connection:(NSURLConnection *)theConnection didReceiveData:(NSData *)incrementalData { if (data==nil) { data = [[NSMutableData alloc] initWithCapacity:2048]; } [data appendData:incrementalData]; } - (void)connectionDidFinishLoading:(NSURLConnection*)theConnection { [connection release]; connection=nil; _imageView.image = [UIImage imageWithData:data]; if (_activityIndicator) { [_activityIndicator stopAnimating]; } [data release]; data=nil; } - (UIImage*) image { UIImageView* iv = [[self subviews] objectAtIndex:0]; return [iv image]; } In ViewController Class Which loads image - (UITableViewCell *)tableView:(UITableView *)tV cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *reuseIdentifier =@"CellIdentifier"; ListCell *cell = (ListCell *)[tableView dequeueReusableCellWithIdentifier:reuseIdentifier]; if (cell==nil) { cell = [[ListCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier]; NSMutableDictionary *dicResult = [arrResults objectAtIndex:indexPath.row]; NSURL *url=[NSURL URLWithString:[dicResult objectForKey:@"Image"]]; AsynchronousImageView *asyncImageView = [[AsynchronousImageView alloc] initWithFrame:CGRectMake(5, 10,80,80)]; [asyncImageView loadImageFromURL:url defaultImageName:@"DefaultImage.png" showDefaultImage:NO showActivityIndicator:YES activityIndicatorRect:CGRectMake(5, 10,30,30) activityIndicatorStyle:UIActivityIndicatorViewStyleGray]; // load our image with URL asynchronously [cell.contentView addSubview:asyncImageView]; // cell.imgLocationView.image = [UIImage imageNamed:[dicResult valueForKey:@"Image"]]; [asyncImageView release]; } if([arrResults count]==1) { UITableViewCell *cell1=[tableView dequeueReusableCellWithIdentifier:reuseIdentifier]; if(cell1==nil) cell1=[[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:reuseIdentifier] autorelease]; NSMutableDictionary *dicResult = [arrResults objectAtIndex:0]; cell1.textLabel.text=[dicResult valueForKey:@"NoResults"]; return cell1; } else { NSMutableDictionary *dicResult = [arrResults objectAtIndex:indexPath.row]; NSString *title = [NSString stringWithFormat:@"%@ Bedrooms-%@", [dicResult valueForKey:KEY_NUMBER_OF_BEDROOMS],[dicResult valueForKey:KEY_PROPERTY_TYPE]]; NSString *strAddress = [dicResult valueForKey:KEY_DISPLAY_NAME]; NSString *address = [strAddress stringByReplacingOccurrencesOfString:@", " withString:@"\n"]; NSString *price = [dicResult valueForKey:KEY_PRICE]; NSString *distance = [dicResult valueForKey:KEY_DISTANCE]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.lblTitle.text = title; cell.lblAddress.text = address; if ([price length]>0) { cell.lblPrice.text = [NSString stringWithFormat:@"£%@",price]; }else{ cell.lblPrice.text = @""; } if ([distance length]>0) { cell.lblmiles.text = [NSString stringWithFormat:@"%.2f miles",[distance floatValue]]; }else{ cell.lblmiles.text = @""; } } return cell; } How can i resolve this? I have attached heapshot analysis screen shot of it.Here non Object consumes so much of memory what is that?

    Read the article

  • How to test a class that makes HTTP request and parse the response data in Obj-C?

    - by GuidoMB
    I Have a Class that needs to make an HTTP request to a server in order to get some information. For example: - (NSUInteger)newsCount { NSHTTPURLResponse *response; NSError *error; NSURLRequest *request = ISKBuildRequestWithURL(ISKDesktopURL, ISKGet, cookie, nil, nil); NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; if (!data) { NSLog(@"The user's(%@) news count could not be obtained:%@", username, [error description]); return 0; } NSString *regExp = @"Usted tiene ([0-9]*) noticias? no leídas?"; NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; NSArray *match = [stringData captureComponentsMatchedByRegex:regExp]; [stringData release]; if ([match count] < 2) return 0; return [[match objectAtIndex:1] intValue]; } The things is that I'm unit testing (using OCUnit) the hole framework but the problem is that I need to simulate/fake what the NSURLConnection is responding in order to test different scenarios and because I can't relay on the server to test my framework. So the question is Which is the best ways to do this?

    Read the article

  • Why Won't this http post request work?

    - by dubbeat
    Hi, I'm wondering why this http post request won't work for my iphone app. I know for a fact that the url is correct and that the variables I'm sending are correct but for some reason the request is not being recieved by the aspx page. NSMutableString *httpBodyString; NSURL *url; NSMutableString *urlString; httpBodyString=[NSMutableString stringWithFormat:@"%@%@%@%@%@",@"?g=",promoValueObject.country,@"&c=",promoData.artistid,@"&d=iphone"]; urlString=[[NSMutableString alloc] initWithString:@"http://www.mysite.com/stats_promo.aspx"]; url=[[NSURL alloc] initWithString:urlString]; [urlString release]; NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url]; [url release]; [urlRequest setHTTPMethod:@"POST"]; [urlRequest setHTTPBody:[httpBodyString dataUsingEncoding:NSISOLatin1StringEncoding]]; //[httpBodyString release]; NSURLConnection *connectionResponse = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self]; if (!connectionResponse) { NSLog(@"Failed to submit request"); } else { NSLog(@"--------- Request submitted ---------"); NSLog(@"connection: %@ method: %@, encoded body: %@, body: %a", connectionResponse, [urlRequest HTTPMethod], [urlRequest HTTPBody], httpBodyString); }

    Read the article

  • iPhone Twitter Integration: Validating login.

    - by Mr. McPepperNuts
    The following code posts to twitter: NSString *compoundLoginString = [NSString stringWithFormat:@"http://%@:%@@twitter.com/statuses/update.xml",extractedUsername, extractedPassword]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [NSURL URLWithString:compoundLoginString] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0]; // The text to post NSString *msg = tweetText; [request setHTTPMethod:@"POST"]; [request setHTTPBody:[[NSString stringWithFormat:@"status=%@", msg] dataUsingEncoding:NSASCIIStringEncoding]]; NSURLResponse *response; NSError *error; if ([NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error] != nil){ [self postSuccessfulAlert]; }else{ [self postNotSuccessfulAlert]; } I am curious as to how I could check if the username and password is correct before proceeding to the above piece of code. I found the following code in a tutorial, but am unsure how I would implement or call this function. - (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge { if ([challenge previousFailureCount] == 0) { NSURLCredential *newCredential; newCredential=[NSURLCredential credentialWithUser:[self username] password:[self password] persistence:NSURLCredentialPersistenceNone]; [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge]; } else { [[challenge sender] cancelAuthenticationChallenge:challenge]; // inform the user that the user name and password // in the preferences are incorrect NSLog(@"Invalid Username or Password"); } } Any ideas? Please note, I have taken snippets of code from both of the following tutorials. http://iphonedevelopertips.com/networking/post-to-a-twitter-account-from-the-iphone.html and http://icodeblog.com/2009/07/09/integrating-twitter-into-your-applications/

    Read the article

  • How to upload image to remote server in iphone?

    - by Atulkumar V. Jain
    Hi Everybody, I am trying to upload a image which i am clicking with the help of the camera. I am trying the following code to upload the image to the remote server. -(void)searchAction:(UIImage*)theImage { UIDevice *dev = [UIDevice currentDevice]; NSString *uniqueId = dev.uniqueIdentifier; NSData * imageData = UIImagePNGRepresentation(theImage); NSString *postLength = [NSString stringWithFormat:@"%d",[imageData length]]; NSString *urlString = [@"http://www.amolconsultants.com/im.jsp?" stringByAppendingString:@"imagedata=iPhoneV0&mcid="]; urlString = [urlString stringByAppendingString:uniqueId]; urlString = [urlString stringByAppendingString:@"&lang=en_US.UTF-8"]; NSLog(@"The URL of the image is :- %@", urlString); NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:urlString]]; [request setHTTPMethod:@"POST"]; [request setValue:postLength forHTTPHeaderField:@"Content-Length"]; [request setHTTPBody:imageData]; NSURLConnection *conn=[[NSURLConnection alloc] initWithRequest:request delegate:self]; if (conn == nil) { NSLog(@"Failed to create the connection"); } } But nothing is getting posted. Nothing comes in the console window also. I am calling this method in the action sheet. When the user clicks on the 1st button of the action sheet this method is called to post the image. Can anyone help me with this... Any code will be very helpful... Thanx in advance...

    Read the article

  • Twitter API Rate Limit - Overcoming on an unauthenticated JSON Get with Objective C?

    - by Cian
    I see the rate limit is 150/hr per IP. This'd be fine, but my application is on a mobile phone network (with shared IP addresses). I'd like to query twitter trends, e.g. GET /trends/1/json. This doesn't require authorization, however what if the user first authorized with my application using OAuth, then hit the JSON API? The request is built as follows: - (void) queryTrends:(NSString *) WOEID { NSString *urlString = [NSString stringWithFormat:@"http://api.twitter.com/1/trends/%@.json", WOEID]; NSURL *url = [NSURL URLWithString:urlString]; NSURLRequest *theRequest=[NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:10.0]; NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES]; if (theConnection) { // Create the NSMutableData to hold the received data. theData = [[NSMutableData data] retain]; } else { NSLog(@"Connection failed in Query Trends"); } //NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]]; } I have no idea how I'd build this request as an authenticated one however, and haven't seen any examples to this effect online. I've read through the twitter OAuth documentation, but I'm still puzzled as to how it should work. I've experimented with OAuth using Ben Gottlieb's prebuild library, and calling this in my first viewDidLoad: OAuthViewController *oAuthVC = [[OAuthViewController alloc] initWithNibName:@"OAuthTwitterDemoViewController" bundle:[NSBundle mainBundle]]; // [self setViewController:aViewController]; [[self navigationController] pushViewController:oAuthVC animated:YES]; This should store all the keys required in the app's preferences, I just need to know how to build the GET request after authorizing! Maybe this just isn't possible? Maybe I'll have to proxy the requests through a server side application? Any insight would be appreciated!

    Read the article

  • Refreshing a MKMapView when the user location is updated or using default values

    - by koichirose
    I'm trying to refresh my map view and load new data from the server when the device acquires the user location. Here's what I'm doing: - (void)viewDidLoad { CGRect bounds = self.view.bounds; mapView = [[MKMapView alloc] initWithFrame:bounds]; mapView.showsUserLocation=YES; mapView.delegate=self; [self.view insertSubview:mapView atIndex:0]; [self refreshMap]; } - (void)mapView:(MKMapView *)theMapView didUpdateUserLocation:(MKUserLocation *)userLocation { //this is to avoid frequent updates, I just need one position and don't need to continuously track the user's location if (userLocation.location.horizontalAccuracy > self.myUserLocation.location.horizontalAccuracy) { self.myUserLocation = userLocation; CLLocationCoordinate2D centerCoord = { userLocation.location.coordinate.latitude, userLocation.location.coordinate.longitude }; [theMapView setCenterCoordinate:centerCoord zoomLevel:10 animated:YES]; [self refreshMap]; } } - (void)refreshMap { [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES]; [self.mapView removeAnnotations:self.mapView.annotations]; //default position NSString *lat = @"45.464161"; NSString *lon = @"9.190336"; if (self.myUserLocation != nil) { lat = [[NSNumber numberWithDouble:myUserLocation.coordinate.latitude] stringValue]; lon = [[NSNumber numberWithDouble:myUserLocation.coordinate.longitude] stringValue]; } NSString *url = [[NSString alloc] initWithFormat:@"http://myserver/geo_search.json?lat=%@&lon=%@", lat, lon]; NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0]; [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; [url release]; [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; } I also have a - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data, to create and add the annotations. Here's what happens: sometimes I get the location after a while, so I already loaded data close to the default location. Then I get the location and it should remove the old annotations and add the new ones, instead I keep seeing the old annotations and the new ones are added anyway (let's say I receive 10 annotations each time, so it means that I have 20 on my map when I should have 10). What am I doing wrong?

    Read the article

  • Multi-Part HTTP Request through xcode

    - by devsri
    Hello Everyone, i want to upload image,video and audio files to a server. I have read this thread on the similar topic but wasn't able to understand completely the flow of the code. It would be great if you can suggest me some sample code or tutorial to start with. I am using the following code to connect without any media to the server [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; NSString *url =[[NSString alloc]initWithFormat:@"%@",[NetworkConstants getURL]]; NSURL *theURL =[NSURL URLWithString:url]; [url release]; NSMutableURLRequest *theRequest =[NSMutableURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:0.0f]; [theRequest setHTTPMethod:@"POST"]; NSString *theBodyString = [NSString stringWithFormat:@"json1=%@&userID=%@",jsonObject,[GlobalConstants getUID]]; NSData *theBodyData = [theBodyString dataUsingEncoding:NSUTF8StringEncoding]; [theRequest setHTTPBody:theBodyData]; NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (conn) { NSLog(@"Successful in sending sync"); } else { NSLog(@"Failed Connection in sending sync"); } [conn release]; It would be really convenient for me if anything could be done editing this part of code. Any form of help would be highly appreciated. Thanks in advance!!

    Read the article

  • Getting memory leak at NSURL connection in Iphone sdk.

    - by monish
    Hi guys, Here Im getting leak at the NSURL connection in my libxml parser can anyone tell how to resolve it. The code where leak generates is: - (BOOL)parseWithLibXML2Parser { BOOL success = NO; ZohoAppDelegate *appDelegate = (ZohoAppDelegate*) [ [UIApplication sharedApplication] delegate]; NSString* curl; if ([cName length] == 0) { curl = @"https://invoice.zoho.com/api/view/settings/currencies?ticket="; curl = [curl stringByAppendingString:appDelegate.ticket]; curl = [curl stringByAppendingString:@"&apikey="]; curl = [curl stringByAppendingString:appDelegate.apiKey]; curl = [curl stringByReplacingOccurrencesOfString:@"\n" withString:@""]; } NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:curl]]; NSLog(@"the request parserWithLibXml2Parser %@",theRequest); NSURLConnection *con = [[[NSURLConnection alloc] initWithRequest:theRequest delegate:self] autorelease];//Memory leak generated here at this line of code. //self.connection = con; //[con release]; // This creates a context for "push" parsing in which chunks of data that are // not "well balanced" can be passed to the context for streaming parsing. // The handler structure defined above will be used for all the parsing. The // second argument, self, will be passed as user data to each of the SAX // handlers. The last three arguments are left blank to avoid creating a tree // in memory. _xmlParserContext = xmlCreatePushParserCtxt(&simpleSAXHandlerStruct, self, NULL, 0, NULL); if(con != nil) { do { [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; } while (!_done && !self.error); } if(self.error) { //NSLog(@"parsing error"); [self.delegate parser:self encounteredError:nil]; } else { success = YES; } return success; } Anyone's help will be muck appreciated . Thank you, Monish.

    Read the article

  • How i finding Internate network error using Try..........Catch in iphone?

    - by Rajendra Bhole
    Hi, I developing an application in which i calling web services on iphone. I want to implement Try.......Catch in that code for catching internet and GPRS connection error.The code is as follow, NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:mainURL5]]; [request setHTTPMethod:@"POST"]; NSHTTPURLResponse* urlResponse = nil; NSError *error = [[[NSError alloc] init] autorelease]; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error]; result5 = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; I was using Try......catch but it didn't work that code as follows, @try { //prepar request NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:mainURL5]]; [request setHTTPMethod:@"POST"]; NSHTTPURLResponse* urlResponse = nil; NSError *error = [[[NSError alloc] init] autorelease]; NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&urlResponse error:&error]; result5 = [[NSMutableString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; } @catch(NSException * e) { [clsMessageBox ShowMessageOK:@"some text" :[e reason]]; }

    Read the article

  • receiving signal: EXC_BAD_ACCESS in web service call function

    - by murali
    I'm new to iPhone development. I'm using xcode 4.2. When I click on the save button, I'm getting values from the html page and my web service is processing them, and then I get the error: program received signal: EXC_BAD_ACCESS in my web service call function. Here is my code: NSString *val=[WebviewObj stringByEvaluatingJavaScriptFromString:@"save()"]; NSLog(@"return value:: %@",val); [adict setObject:[NSString stringWithFormat:@"%i",userid5] forKey:@"iUser_Id" ]; [adict setObject:[[val componentsSeparatedByString:@","]objectAtIndex:0] forKey:@"vImage_Url"]; [adict setObject:[[val componentsSeparatedByString:@","]objectAtIndex:1] forKey:@"IGenre_Id"]; [adict setObject:[[val componentsSeparatedByString:@","]objectAtIndex:2] forKey:@"vTrack_Name"]; [adict setObject:[[val componentsSeparatedByString:@","]objectAtIndex:3] forKey:@"vAlbum_Name"]; [adict setObject:[[val componentsSeparatedByString:@","]objectAtIndex:4] forKey:@"vMusic_Url"]; [adict setObject:[[val componentsSeparatedByString:@","]objectAtIndex:5] forKey:@"iTrack_Duration_min"]; [adict setObject:[[val componentsSeparatedByString:@","]objectAtIndex:6] forKey:@"iTrack_Duration_sec"]; [adict setObject:[[val componentsSeparatedByString:@","]objectAtIndex:7] forKey:@"vDescription"]; NSLog(@"dict==%@",[adict description]); NSString *URL2= @"http://184.164.156.55/Music/Track.asmx/AddTrack"; obj=[[UrlController alloc]init]; obj.URL=URL2; obj.InputParameters = adict; [obj WebserviceCall]; obj.delegate= self; //this is my function..it is working for so many function calls -(void)WebserviceCall{ webData = [[NSMutableData alloc] init]; NSMutableURLRequest *urlRequest = [[ NSMutableURLRequest alloc ] initWithURL: [ NSURL URLWithString: URL ] ]; NSString *httpBody = @""; for(id key in InputParameters) { if([httpBody length] == 0){ httpBody=[httpBody stringByAppendingFormat:@"&%@=%@",key,[InputParameters valueForKey:key]]; } else{ httpBody=[httpBody stringByAppendingFormat:@"&%@=%@",key,[InputParameters valueForKey:key]]; } } httpBody = [httpBody stringByAppendingFormat:httpBody];//Here i am getting EXC_BAD_ACCESS [urlRequest setHTTPMethod: @"POST" ]; [urlRequest setHTTPBody:[httpBody dataUsingEncoding:NSUTF8StringEncoding]]; [urlRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self]; } Can any one help me please? thanks in advance

    Read the article

  • NSMutableURLRequest returns null on real device, while returning image on simulator

    - by Yanchi
    I was testing my app that I've been working on for past 2 months. Basically it requests for JSON, that contains info about items. One field of JSON file is image_url. When I want to display this image, I need to download it from another server, that needs additional credentials. So it goes like this- In my cellForRowAtIndexPath I'm doing NSDictionary *aucdict = [jsonAukResults objectAtIndex:indexPath.row]; NSURL *imageURL = [NSURL URLWithString:[aucdict objectForKey:@"img_url"]]; NSString *authPString = [[[NSString stringWithFormat:@"login:password"]dataUsingEncoding:NSUTF8StringEncoding] base64EncodedString]; NSString *verifPString = [NSString stringWithFormat:@"Image %@",authPString]; NSMutableURLRequest *Prequest = [[NSMutableURLRequest alloc] initWithURL:imageURL]; [Prequest setValue:verifPString forHTTPHeaderField:@"Authorization"]; NSError *error = nil; NSURLResponse *resp = nil; NSData *picresult = [NSURLConnection sendSynchronousRequest:Prequest returningResponse:&resp error:&error]; UIImage *imageLoad = [[UIImage alloc] initWithData:picresult]; Now, I just obscured credentials (they are not login:password :)). My problem is, that right now, I get 3 items. All 3 have image on same server. I can get two of them with this code no problem. However third one is problematic, I always get (NULL) imageLoad. On my simulator, everything works fine, I get all 3 pictures. On real device I get error. I tried to NSURLConnection with error and response so I could debug better. This is what I got in my error. Printing description of error: Error Domain=NSURLErrorDomain Code=-1202 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “server name” which could put your confidential information at risk." UserInfo=0x1e5a3080 {NSErrorFailingURLStringKey=pictureLink.jpg, NSLocalizedRecoverySuggestion=Would you like to connect to the server anyway?, NSErrorFailingURLKey=pictureLink.jpg, NSLocalizedDescription=The certificate for this server is invalid. You might be connecting to a server that is pretending to be “server name” which could put your confidential information at risk., NSUnderlyingError=0x1e5a30e0 "The certificate for this server is invalid. You might be connecting to a server that is pretending to be “server name” which could put your confidential information at risk.", NSURLErrorFailingURLPeerTrustErrorKey=} I dont use SSL so Im really confused as what could cause this error. Btw, everything worked fine until now (this is my initial screen, so it's been done for good month and a half). Now I started to do graphics and this problem popped up :(

    Read the article

  • Using the PayPal API in an iPhone application

    - by jaynaiphone
    Hello I want to use Paypal in my iphone application, I have find the soapRequest to integrating the paypal API. My code is NSString *soapMessage = [NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" "<SOAP-ENV:Envelope xmlns:xsi= \"http://www.w3.org/2001/XMLSchema-instance\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n" "<SOAP-ENV:Header>\n" "<RequesterCredentials xmlns=\"urn:ebay:api:PayPalAPI\">\n" "<Credentials xmlns=\"urn:ebay:apis:eBLBaseComponents\">\n" "<Username>api_username</Username>\n" "<Password>api_password</Password>\n" "<Signature/>\n" "<Subject/>\n" "</Credentials>\n" "</RequesterCredentials>\n" "</SOAP-ENV:Header>\n" "<SOAP-ENV:Body>\n" "<specific_api_name_Req xmlns=\"urn:ebay:api:PayPalAPI\">\n" "<specific_api_name_Request>\n" "<Version xmlns=urn:ebay:apis:eBLBaseComponents”>service_version</Version>\n" "<required_or_optional_fields xsi:type=”some_type_here”>\n" "</required_or_optional_fields>\n" "</specific_api_name_Request>\n" "</specific_api_name_Req>\n" "</SOAP-ENV:Body>\n" "</SOAP-ENV:Envelope>\n"]; NSLog(@"Soap message===%@",soapMessage); NSString *parameterString = [NSString stringWithFormat:@"USER=%@&PWD=%@&SIGNATURE=%@&VERSION=57.0&METHOD=SetMobileCheckout&AMT=%.2f&CURRENCYCODE=USD&DESC=%@&RETURNURL=%@", userName, password, signature, donationAmount, @"Some Charge", returnCallURL]; NSLog(parameterString); NSURL *url = [NSURL URLWithString:paypalUrlNVP]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url]; NSString *msgLength = [NSString stringWithFormat:@"%d", [parameterString length]]; [theRequest addValue: msgLength forHTTPHeaderField:@"Content-Length"]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody: [parameterString dataUsingEncoding:NSUTF8StringEncoding]]; NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if( theConnection ){ webData = [[NSMutableData data] retain]; // [self displayConnectingView]; }else{ NSLog(@"theConnection is NULL"); } But here I am not getting the value of paypalUrlNVP. How can i get it?? And if possible then please give some example of paypalAPI integration in iphone. I also want to use checkout functionality.I am new in this field so I have no idea about it. So, kindly give me whole sample code. Thanks in advance.

    Read the article

  • iPhone SDK:HTML parsing standard way or example:

    - by Clave Martin
    Hi, I am accessing a web page using NSURLConnection and have a HTML data downloaded programmatically in my iPhone client application. I want to parse and pick some description data from the HTML tags..It is too dirty tags and my data is also here and there. I would like to ask you, is there a standard or easy way of parsing of HTML data on iPhone development. P.S: I know about XML parsing. thanks. Clave/

    Read the article

  • IOS - Performance Issues with SVProgressHUD

    - by ScottOBot
    I have a section of code that is producing pour performance and not working as expected. it utilizes the SVProgressHUD from the following github repository at https://github.com/samvermette/SVProgressHUD. I have an area of code where I need to use [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]. I want to have a progress hud displayed before the synchronous request and then dismissed after the request has finished. Here is the code in question: //Display the progress HUB [SVProgressHUD showWithStatus:@"Signing Up..." maskType:SVProgressHUDMaskTypeClear]; NSError* error; NSURLResponse *response = nil; [self setUserCredentials]; // create json object for a users session NSDictionary* session = [NSDictionary dictionaryWithObjectsAndKeys: firstName, @"first_name", lastName, @"last_name", email, @"email", password, @"password", nil]; NSData *jsonSession = [NSJSONSerialization dataWithJSONObject:session options:NSJSONWritingPrettyPrinted error:&error]; NSString *url = [NSString stringWithFormat:@"%@api/v1/users.json", CoffeeURL]; NSURL *URL = [NSURL URLWithString:url]; NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/json" forHTTPHeaderField:@"Accept"]; [request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [request setValue:[NSString stringWithFormat:@"%d", [jsonSession length]] forHTTPHeaderField:@"Content-Length"]; [request setHTTPBody:jsonSession]; NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error]; NSString *dataString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSDictionary *JSONResponse = [NSJSONSerialization JSONObjectWithData:[dataString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers error:&error]; NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; NSInteger statusCode = httpResponse.statusCode; NSLog(@"Status: %d", statusCode); if (JSONResponse != nil && statusCode == 200) { //Dismiss progress HUB here [SVProgressHUD dismiss]; return YES; } else { [SVProgressHUD dismiss]; return NO; } For some reason the synchronous request blocks the HUB from being displayed. It displays immediately after the synchronous request happens, unfortunatly this is also when it is dismissed. The behaviour displayed to the user is that the app hangs, waits for the synchronous request to finish, quickly flashes the HUB and then becomes responsive again. How can I fix this issue? I want the SVProgressHUB to be displayed during this hang time, how can I do this?

    Read the article

  • iPhone JSON Object

    - by Cosizzle
    Hello, I'm trying to create a application that will retrieve JSON data from an HTTP request, send it to a the application main controller as a JSON object then from there do further processing with it. Where I'm stick is actually creating a class that will serve as a JSON class in which will take a URL, grab the data, and return that object. Alone, im able to make this class work, however I can not get the class to store the object for my main controller to retrieve it. Because im fairly new to Objective-C itself, my thoughts are that im messing up within my init call: -initWithURL:(NSString *) value { responseData = [[NSMutableData data] retain]; NSString *theURL = value; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:theURL]]; [[NSURLConnection alloc] initWithRequest:request delegate:self]; return self; } The processing of the JSON object takes place here: - (void)connectionDidFinishLoading:(NSURLConnection *)connection { [connection release]; NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; [responseData release]; NSError *jsonError; SBJSON *json = [[SBJSON new] autorelease]; NSDictionary *parsedJSON = [json objectWithString:responseString error:&jsonError]; // NSArray object. listings = [parsedJSON objectForKey:@"posts"]; NSEnumerator *enumerator = [listings objectEnumerator]; NSDictionary* item; // to prove that it does work. while (item = (NSDictionary*)[enumerator nextObject]) { NSLog(@"posts:id = %@", [item objectForKey:@"id"]); NSLog(@"posts:address = %@", [item objectForKey:@"address"]); NSLog(@"posts:lat = %@", [item objectForKey:@"lat"]); NSLog(@"posts:lng = %@", [item objectForKey:@"lng"]); } [responseString release]; } Now when calling the object within the main controller I have this bit of code in the viewDidLoad method call: - (void)viewDidLoad { [super viewDidLoad]; JSON_model *jsonObj = [[JSON_model alloc] initWithURL:@"http://localhost/json/faith_json.php?user=1&format=json"]; NSEnumerator *enumerator = [[jsonObj listings] objectEnumerator]; NSDictionary* item; // while (item = (NSDictionary*)[enumerator nextObject]) { NSLog(@"posts:id = %@", [item objectForKey:@"id"]); NSLog(@"posts:address = %@", [item objectForKey:@"address"]); NSLog(@"posts:lat = %@", [item objectForKey:@"lat"]); NSLog(@"posts:lng = %@", [item objectForKey:@"lng"]); } }

    Read the article

  • willSendRequest redirectResponse doesn't work in iPhone SDK2.0

    - by WholeIphone
    I use the delegate method connection:willSendRequest:redirectResponse: in SDK 2.2, the code like below: - (NSURLRequest *)connection:(NSURLConnection *)con willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse { if(redirectResponse) { if(!self.autoRedirect) { NSLog(@"response will redirect"); request = nil; } } return request; if the request is returned to nil ,it seems it hangs up here, and delegate didReceiveData will not get called. but it works in SDK 3. Any suggestions about this?

    Read the article

  • Security in Iphone?

    - by adusum
    Is There any concept of HTTPS in Iphone.how iphone apps are safe? if we are developing any apps related to some security?how can we provide security to iphone apps. I know that NSURL,NSURLConnection classes contains in Build HTTP but is there any concept of HTTPS? Thanks,

    Read the article

  • Strange problem with NSMutableArray - Possibly some memory corruption

    - by user210504
    Hi! I am trying to update data in a table view using a NSMutableArray. Quite simple :( What is happening is that I get my data from a NSURLConnection Callback, which I parse and store it in an array and call reload data on the table view. The problem is that when cellForRowAtIndexPath is called back by the framework. The array still shows the correct count of the elements but all string objects I had stored earlier are shown as invalid. Any pointers

    Read the article

  • Profile Image Update Twitter API

    - by jshollax
    I am trying to upload a profile image to twitter using their API. I found some good examples on the web on how to format the URLRequest, however I just can't seem to get this to work. Any help would be appreciated. The URL that I am using from Twitter API is http://twitter.com/account/update_profile_image.json -(void)uploadImageForAccount:(NSURL *)theURL intUserName:(NSString *)_userName initPassWord:(NSString *)_passWord image:(NSData *)image{ userName = [_userName retain]; passWord = [_passWord retain]; UIApplication *app = [UIApplication sharedApplication]; app.networkActivityIndicatorVisible = YES; requestedData = [[NSMutableData alloc] initWithLength:0]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:theURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60]; [theRequest setHTTPMethod:@"POST"]; NSString *stringBoundary = [NSString stringWithString:@"0xKhTmLbOuNdArY"]; NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", stringBoundary]; [theRequest addValue:contentType forHTTPHeaderField:@"Content-Type"]; // Credentials NSString *creds = [NSString stringWithFormat:@"%@:%@", userName, passWord]; [theRequest addValue:[NSString stringWithFormat:@"Basic %@",[self base64encode:creds]] forHTTPHeaderField:@"Authorization"]; NSMutableData *postBody = [NSMutableData data]; [postBody appendData:[[NSString stringWithFormat:@"\r\n\r\n--%@\r\n", stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithString:@"Content-Disposition: form-data; name=\"source\"\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithString:@"canary"] dataUsingEncoding:NSUTF8StringEncoding]]; NSString *mimeType = mimeType = @"image/jpeg"; [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"media\"; filename=\"%@\"\r\n", @"TNImage.jpeg"] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n", mimeType] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:[[NSString stringWithString:@"Content-Transfer-Encoding: binary\r\n\r\n"] dataUsingEncoding:NSUTF8StringEncoding]]; [postBody appendData:image]; [postBody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",stringBoundary] dataUsingEncoding:NSUTF8StringEncoding]]; [theRequest setHTTPBody:postBody]; NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self startImmediately:YES]; if(DEBUG) NSLog(@"Connection = %@",[connection description]); if (connection == nil) { if(DEBUG) NSLog(@"Connection was Nil"); } }

    Read the article

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