我正在使用 asi-http-request 将文件上传到服务器。 我的代码用于工作正常,直到某些时候它开始崩溃。 崩溃发生在两个方面: - 文件正在正确上传,进度正常,直到结束,然后整个应用程序崩溃。 - 当用户按“取消”按钮以取消上传时。
我在控制台上收到此错误: 抛出'NSException'实例后终止调用 和:线程1:编程接收信号:SIGABRT
这是我看到的2个错误。没有更多信息。
这是代码:
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 stringWithFormat:@"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];
谁能告诉我有什么问题?也许这是一个记忆问题?
答案 0 :(得分:1)
“didFinish ...”和“didFail ...”委托方法没有代码。
还要确保在下载完成或取消之前,代理实例(此处为“self”)未被取消分配。