View Conroller를 밀고 나면 세그먼트 컨트롤러를 통해 팝업하여 원래 상태로 되돌립니다. 몇 가지 값이 변경됩니다. 하나는 거리 값 (float)이고 다른 하나는 이진 데이터로 저장되는 미리보기 이미지입니다.ViewController를 푸시하고 팝핑하면 코어 데이터 객체가 값을 잃게됩니다
다른보기 컨트롤러를 푸시하기 전에 코어 데이터가 본질적으로이 배열 (현재 배열 임)을 알리는 방법이 있습니까? 어쩌면 그것을 tmpArray에 복사 한 다음 viewDidAppear에 해당 tmpArray를 다시 복사하십시오. 정말 해킹 된 것 같지만이 기능을 작동시켜야합니다. 그래서 여기
들으
편집 # 1
는 일이 잘못 곳 주변에 일부 코드입니다. 그것의 원인이되는 getAllLocationsWithFinished 것 같아 그래서 self.tmpLocations는 변경 :
//works
NSLog(@"#1 locations right before call: %@",[self.locations objectAtIndex:2]);
self.tmpLocations=[[NSArray alloc] initWithArray:[self.locations copy]];
//works
NSLog(@"#2 locations right before call: %@",[self.tmpLocations objectAtIndex:2]);
[[ModelManager sharedModelManager] getAllLocationsWithFinished:^(NSArray* map_locations)
{
// data is off
NSLog(@"#3 locations right before call: %@",[self.tmpLocations objectAtIndex:2]);
메인 스레드에서'getAllLocationsWithFinished' 콜백 메소드가 호출되고 있습니까? 또한'tmpLocations' 속성을 어떻게 선언합니까? 강한? 블록을 실행하기 전에, 그리고 당신의 위치 배열을 가진 프로퍼티를 할당 한 후에 다음을 시도하십시오 :'__block NSArray * testArray = self.tmpLocations; 그런 다음 NSLog는 블록 안의'* testArray'를 NSLog합니다. – Rog
tmpLocations의 선언 강도가 높습니다. 백그라운드 스레드에서 getAllLocationsWithFinished가 실행됩니다. NSLog testArray 때 distance 및 defaultImageData 모두 nil 있습니다. 다른 값은 백그라운드 작업을 위해 GCD를 사용하지 않고 – timpone