2013-10-08 2 views
0

진행중인 NSManagedObjectContext performBlockAndWait 프로세스를 취소하는 방법은 무엇입니까? 어쨌든 그렇게 할 것입니다. 사용자가 삭제되어 1000 개의 항목을 저장하지 않으려는 경우 취소하고 싶습니다.performBlockAndWait에서 NSManagedObjectContext 작업을 취소하십시오.

[context performBlockAndWait:^{ 
     NSError *childError = nil; 
     if ([context save:&childError]) 
     { 
      [context.parentContext performBlockAndWait:^{ 
       NSError *parentError = nil; 
       if ([context.parentContext save:&parentError]) 
       { 
        // something here 
       } 
       else 
       { 
        // error 
       } 
      }]; 
     } 
     else 
     { 
      // error 
     } 
    }]; 
+0

'performBlockAndWait'에 어떤 종류의 루프가 있습니까? –

답변

2

performBlockAndWait을 취소하지 않으려면 API가 지원되지 않습니다.

제공 한 블록이 완료 될 때까지 호출이 실행됩니다. 어떤 이유로 일찍 퇴장해야하는 경우 깃발에서 퇴장 할 때라고 말하면 차단을 해제하고 작업을 중단해야합니다. 외부에서 강제로 멈출 수는 없습니다. 당신은 끝내고 안에서 안에서 나올 필요가있다. 현재 사용중인 전화 번호가 performBlockAndWait 인 경우 작동하지 않는다면 해당 코드를 리팩토링하여 현재 상태로 살 수 있습니다.

관련 문제