Wednesday, May 1, 2013

NSURLConnection start example ios


start

Causes the connection to begin loading data, if it has not already.
- (void)start
Discussion of [NSURLConnection start]
Calling this method is necessary only if you create a connection with theinitWithRequest:delegate:startImmediately: method and provide NO for thestartImmediately parameter. If you don’t schedule the connection in a run loop or an operation queue before calling this method, the connection is scheduled in the current run loop in the default mode.
Example of [NSURLConnection start]
NSURLConnection * connection = [[NSURLConnection alloc] 
                                initWithRequest:request
                                       delegate:self startImmediately:NO];

[connection scheduleInRunLoop:[NSRunLoop mainRunLoop] 
                      forMode:NSDefaultRunLoopMode];
[connection start];
Example of [NSURLConnection start]
NSURLConnection* connection = [[NSURLConnection alloc] initWithRequest:request delegate:nil];
[connection start];
[connection autorelease];
Example of [NSURLConnection start]
- (void)startDownload
{
    NSLog(@"%@ %@",@"Started downloading", feedRecord.profilePicture); // this shows in log
    self.activeDownload = [NSMutableData data];
    // alloc+init and start an NSURLConnection; release on completion/failure
    NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:
                            [NSURLRequest requestWithURL:
                            [NSURL URLWithString:feedRecord.profilePicture]] delegate:self];
    self.imageConnection = conn;
    NSLog(@"%@",conn); // this shows in log
    [conn start];
    [conn release];
}