0

이 항목에 대한 여러 가지 질문을 보았지만 좋은 답을 찾지 못했습니다.SearchDisplayController : [Object _existingView] : 인스턴스로 전송 된 인식 할 수없는 selector

저는 UITableViewController를 사용하는 앱을 가지고 있으며 SearchDisplayController를 인스턴스화합니다. 항상 앱 코드에서 내부 객체가 아닌 하나입니다 것을 제외하고

내가 개체 아무것도 할 수있다

[Object _existingView]: unrecognized selector sent to instance 

처럼 때마다 보이는 나의 충돌 기자에서 무작위로 충돌을 받고, 전혀 규칙은 없다 .

다른 버전의 iOS에 최대 6.0까지 영향을 미칠 수 있습니다.

이 해제 된하지 않은 SearchDisplayController처럼 보인다 (아래 충돌 보고서 참조) 내부 객체에 회전 메시지를 보내는

정말 이상하고 위의 코드는 내가 모두에서 searchDisplayController를 인스턴스화하는 유일한 장소입니다 프로젝트 수업.

이 문제를 재현 할 수 있으면 여기에 게시물을 올리지는 않겠지 만 불행히도 재현 할 수 없었습니다. 심지어 앱 자체에서 수십 개의 UITableViewController를 탐색하고 모의 실험 장치. 사람이 이전에이 문제가 발생했다면

, 그것은 재미있을 수 있고 어쩌면 우리는

이것은 검색 창 및 SearchDisplayController 생성하는 방법이다 (이 여러 게시물)이 주제에 대한 명확한 답을 제공 할 수 있습니다

UISearchBar *searchBar = [[[UISearchBar alloc] init] autorelease]; 
searchBar.barStyle = UIBarStyleBlack; 
self.createdSearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]; 
self.searchDisplayController.searchResultsDelegate = self; 
self.searchDisplayController.searchResultsDataSource = self; 
self.searchDisplayController.delegate = self; 
searchBar.frame = CGRectMake(0, 0, 0, 38); 
self.tableView.tableHeaderView = searchBar; 

일부 답변을 읽은 후에는 약한 링크 여야하지만 dealloc 메서드를 nil 대리자로 업그레이드했습니다. 이 내가 할당 해제 (죄송합니다, 사전 ARC 코드, 난 여전히 업그레이드해야)이 할당을 해제하고있어 어떻게 다음 SearchDisplayController가 제대로 해제되는 경우에도, 난 아직 확실 해요

[[NSNotificationCenter defaultCenter] removeObserver:self]; 
fetchedResultsController.delegate = nil; 
self.searchDisplayController.delegate = nil; 
self.searchDisplayController.searchResultsDelegate = nil; 
self.searchDisplayController.searchResultsDataSource = nil; 
[createdSearchDisplayController release]; 

I 돈 searchDisplayController는 읽기 전용 속성이므로 다른 방법을 사용하지 마십시오.

인스트루먼트 사용 누출 추적을 사용하여 누출이 보이지 않지만 할당 추적을 보면 시뮬레이터에서 여러 메모리 경고를 보낸 후에도 시스템이 searchDiplayController에 대한 참조를 유지하고있는 것처럼 보입니다. 첫 번째 문을 제외하고 우리의 응용 프로그램의 언급은 없다 충돌 보고서, 아래

는 메인 시작 :

0 CoreFoundation 0x35b0b88f __exceptionPreprocess + 162 
1 libobjc.A.dylib 0x3372f259 objc_exception_throw + 32 
2 CoreFoundation 0x35b0ea9b -[NSObject doesNotRecognizeSelector:] + 174 
3 CoreFoundation 0x35b0d915 ___forwarding___ + 300 
4 CoreFoundation 0x35a68650 _CF_forwarding_prep_0 + 48 
5 UIKit 0x334d4ebb -[UISearchDisplayController windowWillAnimateRotation:] + 126 
6 Foundation 0x34f254ff __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 18 
7 CoreFoundation 0x35ad7547 ___CFXNotificationPost_block_invoke_0 + 70 
8 CoreFoundation 0x35a63097 _CFXNotificationPost + 1406 
9 Foundation 0x34e993eb -[NSNotificationCenter postNotificationName:object:userInfo:] + 66 
10 UIKit 0x332efa57 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 3450 
11 UIKit 0x33380fa7 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 46 
12 UIKit 0x33380f37 -[UIWindow _setRotatableViewOrientation:duration:force:] + 70 
13 UIKit 0x3324fa01 -[UIWindow _updateToInterfaceOrientation:duration:force:] + 108 
14 UIKit 0x33236cff -[UIWindow _updateInterfaceOrientationFromDeviceOrientation:] + 162 
15 UIKit 0x332500c7 -[UIWindow _updateInterfaceOrientationFromDeviceOrientationIfRotationEnabled:] + 74 
16 Foundation 0x34f254ff __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 18 
17 CoreFoundation 0x35ad7547 ___CFXNotificationPost_block_invoke_0 + 70 
18 CoreFoundation 0x35a63097 _CFXNotificationPost + 1406 
19 Foundation 0x34e993eb -[NSNotificationCenter postNotificationName:object:userInfo:] + 66 
20 UIKit 0xdeb -[UIDevice setOrientation:animated:] + 214 
21 UIKit 0x3320c16f -[UIApplication handleEvent:withNewEvent:] + 2718 
22 UIKit 0x3320b567 -[UIApplication sendEvent:] + 54 
23 UIKit 0x3320af3b _UIApplicationHandleEvent + 5826 
24 GraphicsServices 0x337fd22b PurpleEventCallback + 882 
25 CoreFoundation 0x35adf523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38 
26 CoreFoundation 0x35adf4c5 __CFRunLoopDoSource1 + 140 
27 CoreFoundation 0x35ade313 __CFRunLoopRun + 1370 
28 CoreFoundation 0x35a614a5 CFRunLoopRunSpecific + 300 
29 CoreFoundation 0x35a6136d CFRunLoopRunInMode + 104 
30 GraphicsServices 0x337fc439 GSEventRunModal + 136 
31 UIKit 0x33239cd5 UIApplicationMain + 1080 
32 AppName 0x0001a1cb main + 66 
33 AppName 0x00016348 start + 40 

답변

0

위의 코드는 확실히 누출하지만 미묘한 방식으로되어있다. 악기에 누출이있는 것은 보이지 않지만 힙에서 할당을 추적하면 계속 누적되는 것을 볼 수 있습니다.

아무 래도 내 질문에 대한 내 질문에 나에게 할당 해제 문제에 대한 답변을 주었다.

// This is not possible and not correct. 
self.searchDisplayController = nil 

을하지만 그렇지 않습니다 :

애플이 searchDisplayController를 만들기위한 매우 이상한 행동을하고 그들이 그것을 읽기 전용 속성을 만든 일을 우리의 표준 방법으로 더욱 혼란이 작동하지 않습니다 그 (것)들에게 방출을 보낼다는 것을 의미한다!

// This is the only correct way of releasing a searchDisplayController from a TableView 
[self.searchDisplayController release] 

2 곳에서 호출해야합니다 물론 당신의 dealloc 방법에

  • .
  • searchBar 및 SDC를 만드는 alloc 메서드에.

그래서 정확하고 정말 searchDisplayController을 만들어 무료로 방법을 누설하다 :

// Alloc and create searchBar + searchDisplayController 
if (self.searchDisplayController) [self.searchDisplayController release]; 
UISearchBar *searchBar = [[[UISearchBar alloc] init] autorelease]; 
searchBar.barStyle = UIBarStyleBlack; 
[[UISearchDisplayController alloc] initWithSearchBar:searchBar contentsController:self]; 
self.searchDisplayController.searchResultsDelegate = self; 
self.searchDisplayController.searchResultsDataSource = self; 
self.searchDisplayController.delegate = self; 
searchBar.frame = CGRectMake(0, 0, 0, 38); 
self.tableView.tableHeaderView = searchBar; 

// Dealloc 
[NSNotificationCenter defaultCenter] removeObserver:self]; 
fetchedResultsController.delegate = nil; 
self.searchDisplayController.delegate = nil; 
self.searchDisplayController.searchResultsDelegate = nil; 
self.searchDisplayController.searchResultsDataSource = nil; 
[self.searchDisplayController release]; 

이 여러 통화 후 악기의 성장 0 힙 것으로 확인되었습니다. 다른 iOS 버전에서도 테스트를 마쳤습니다. 4.3/5.0/5.1 및 6.0

현재 회전 문제와 _existingView에 대한 인식 할 수없는 호출을 해결하는지 확실하지 않지만 UITableViewController에 사용 된 searchDisplayController를 올바르게 할당 해제하는 문제를 해결했습니다.

정답이 전혀없는 포럼의 정기 질문에 대한 답변입니다.

물론 애플리케이션이 최종적으로 해결되었는지 확인하기 위해 수정 사항을 게시하면 충돌 문제를 업데이트합니다 (문제를 재현 할 수 없음).

+0

업데이트 된 버전이 4 일 동안 Store에 게시되었습니다. 기존보기의 문제는 더 이상 발생하지 않습니다. 따라서 SearchDisplay 컨트롤러를 올바르게 릴리스하지 않으면 회전 문제와 예기치 않은 충돌이 발생할 수 있습니다. 위의 솔루션은 앱 내에서 searchDisplayController를 만들고 릴리스하기 위해 노력하고 있습니다. –

관련 문제