people
이라는 Person
개체의 변경 가능한 배열을 포함하는 AppController
클래스가 있습니다. 각 사람은 단순히 NSString과 부동 소수점을가집니다.자신을 NSArrayController가 아닌 배열에 옵저버로 추가합니까?
나는 또한 이 AppController의 people
배열에 바인딩 된 NSArrayController
을 가지고 있습니다. 그런 다음 어레이 컨트롤러에 바인드 된 테이블 뷰의 일반적인 설정을 사용하여 모든 person 객체의 목록을 표시합니다.
내 AppController 클래스에서 실행 취소 지원을 추가하기 위해 people 배열의 옵저버로 등록하려고했습니다. 방법은 다음과 같습니다.
이 코드를 사용하면 person 개체를 성공적으로 추가 한 다음 실행을 취소 할 수 있습니다. 그러나 나는 person 객체 삭제를 취소 할 수 없다. 나는 유일한 사람이 아니에요처럼하지만,
[<NSCFArray 0x3009a0> addObserver:forKeyPath:options:context:] is not supported. Key path: personName
어떤 아이디어를 내가 삭제 작업을 취소 할 때 항상이 예외가?
UPDATE :
가 여기에 역 추적입니다 : 무슨 일이에요
#0 0x7fff8161b41e in -[NSArray(NSKeyValueObserverRegistration) addObserver:forKeyPath:options:context:]
#1 0x7fff8822fc47 in -[_NSModelObservingTracker _registerOrUnregister:observerNotificationsForModelObject:]
#2 0x7fff883b2bb9 in -[_NSModelObservingTracker startObservingModelObjectAtReferenceIndex:]
#3 0x7fff883acc41 in -[_NSModelObservingTracker setObservingToModelObjectsRange:]
#4 0x7fff883aca5a in -[NSTableBinder tableView:updateVisibleRowInformation:]
#5 0x7fff883ac98e in -[_NSBindingAdaptor tableView:updateVisibleRowInformation:]
#6 0x7fff882b4c7b in -[NSTableView drawRect:]
#7 0x7fff882ab081 in -[NSView _drawRect:clip:]
#8 0x7fff882a9cf4 in -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
#9 0x7fff882aa05e in -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
#10 0x7fff882aa05e in -[NSView _recursiveDisplayAllDirtyWithLockFocus:visRect:]
#11 0x7fff882a83c6 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
#12 0x7fff882a9292 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
#13 0x7fff882a9292 in -[NSView _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
#14 0x7fff882a7ee8 in -[NSThemeFrame _recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
#15 0x7fff882a479a in -[NSView _displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
#16 0x7fff8821dff6 in -[NSView displayIfNeeded]
#17 0x7fff88218ea2 in _handleWindowNeedsDisplay
#18 0x7fff81da9077 in __CFRunLoopDoObservers
#19 0x7fff81d84ef4 in __CFRunLoopRun
#20 0x7fff81d8484f in CFRunLoopRunSpecific
#21 0x7fff8836ab31 in _NSUnhighlightCarbonMenu
#22 0x7fff8834d0c1 in -[NSMenu performKeyEquivalent:]
#23 0x7fff8834be69 in -[NSApplication _handleKeyEquivalent:]
#24 0x7fff8821caa1 in -[NSApplication sendEvent:]
#25 0x7fff881b3922 in -[NSApplication run]
#26 0x7fff881ac5f8 in NSApplicationMain
#27 0x100001469 in main at main.m:13
'personName'을 (를) 관찰 한 코드를 게시하십시오. 또한,'[super init]'보다는'self = [super init];을 사용하십시오. – Yuji
나는 personName을 관찰하지 않는다. 그래서 나는 혼란 스럽다. NSArrayController는 NSCFArray에 대해 -addObserver : forKeyPath : options : context :를 호출하는 노드라고 생각합니다. – jasonbogd
더 명확하게하기 위해 질문을 업데이트했습니다. 감사. – jasonbogd