I'm using NSURLConnection as listed below. I have three questions about this class. When I concatenate the url value, the debugger hits this line twice but not the line above it:
if (theConnection){
The second time I get EXC_BAD_ACCESS. Using the first url assignment (commented out) works fine.
1.) What's the difference?
- (void)applicationDidFinishLaunching:(UIApplication *)application {
//NSString *url = @"http://www.abc.com/afile.mp4";
NSString *temp = @"afile.mp4";
NSString *url = [@"http://www.abc.com/" stringByAppendingString:temp];
theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url]
cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];
[url release];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
receivedData=[[NSMutableData data] retain];
}
2.) If I change the file name to afile.mp, the request goes through and [receivedData length] has a value of around 1600 when
- (void)connectionDidFinishLoading:(NSURLConnection *)connection
gets hit. Is there a way to accurately check if receivedData has the actual data you are requesting. The target file is about 7MB but can vary from 1.5MB to 9MB. The resource I requested wasn't there but does anything indicate that?
3.) I'm doing this in my app delegate. The only protocol there is UIApplicationDelegate. How do all of the NSURLConnection methods work if there isn't a delegate for them?