0
我有一個類方法內的下一個問題,當實現一些長期運行的過程,那就是傳遞的參數似乎被釋放。使用方法參數之前,它被釋放使用
我在課堂外調用該方法。
+ (void)downloadVideoForExercise:(Exercise *)exercise{
dispatch_queue_t serialQueue = dispatch_queue_create("com.blah.queue", DISPATCH_QUEUE_SERIAL);
dispatch_async(serialQueue, ^{
[self isMaximumDownloadCapacityReached:^(BOOL success) {
if (success) {
return;
}
}];
[self shouldDownloadVideoForExercise:exercise
andCompletionBlock:^(BOOL success) {
if (success == NO) {
return;
}
}];
[NetworkManager downloadFileFromURL:exercise.videoServerURL
andSaveLocally:YES
andCompletion:^(BOOL success) {
dispatch_async(dispatch_get_main_queue(), ^{
RLMRealm *realm = [RLMRealm defaultRealm];
if (![realm inWriteTransaction]) {
[realm beginWriteTransaction];
}
if (success) {
//save the new local link
NSString *videopath = [NetworkManager getVideoLocalURLFromServerURLForExercise:exercise.videoServerURL];
exercise.videoLocalURL = videopath;
//change flag for ExerciseVideoDownloadState
exercise.videoDownloadState = isDownloadCompleted;
}else{
//change flag for ExerciseVideoDownloadState
exercise.videoDownloadState = isNotDownloaded;
}
if ([realm inWriteTransaction]) {
[realm commitWriteTransaction];
}
});
}];
});
}
我已經想過使用傳遞的參數與__strong或__block 但沒有成功。 提前感謝您提供的任何幫助。
你指哪個參數?這將有所幫助。 –
我指的是傳遞給方法的參數,在這種情況下是對象:'(Exercise *)exercise' –
你是什麼意思「似乎被解除分配」? – newacct