I am using asi-http-request to upload a file to server. My code used to work OK, until at some point it started crashing. The crash happens in 2 ways: - The file is being uploaded properly and the progress is working OK, until is reaches to the end and then the entire app crash. - When user press the "Cancel" button in order to cancel the upload.
I get this error on the console: terminate called after throwing an instance of 'NSException' and: Thread 1: Program received signal: SIGABRT
These are the 2 errors I see. No more information.
This is the code:
request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:UPLOAD_URL_DEV]];
[request setDelegate:self];
[request setFile:videoFile forKey:@"video"];
[request setPostValue:longitude forKey:@"longitude"];
[request setPostValue:latitude forKey:@"latitude"];
[request setPostValue:horizontalAccuracy forKey:@"accuracytHorizontal"];
[request setPostValue:verticalAccuracy forKey:@"accuracyVertical"];
[request setPostValue:context forKey:@"context"];
[request setPostValue:[UIDevice currentDevice].uniqueIdentifier forKey:@"deviceId"];
NSLog([NSString stringWithFormat:@"Upload Recording time: %@", currentTime]);
[request setPostValue:currentTime forKey:@"time"];
NSLog([NSString stringWithFormat:@"Facebook access token: %@", facebook.accessToken]);
[request setPostValue:facebook.accessToken forKey:@"accessToken"];
NSLog([NSString stringWithF开发者_StackOverflow社区ormat:@"Facebook user id: %@", [defaults objectForKey:@"facebook_user_id"]]);
[request setPostValue:[defaults objectForKey:@"facebook_user_id"] forKey:@"userId"];
[request setUploadProgressDelegate:uploadProgress];
uploadProgress.progress = 0;
uploadProgress.hidden = NO;
labelSendVideo.hidden = NO;
NSLog(@"Starting async upload");
[request startAsynchronous];
Can anyone tell me what is wrong? Maybe it is a memory issue?
There is no code for the "didFinish..." and "didFail..." delegate methods.
Also make sure that the delegate instance (the "self" here) is not getting deallocated before the download is finished or cancelled.
精彩评论