2011-05-14 2 views
0

IB 바인딩을 사용하여 NSTableColumn의 바운드 데이터 정렬.InterfaceBuilder 바인딩을 사용하여 NSTableColumn에서 바운드 데이터를 정렬하는 방법은 무엇입니까?

키 : NSTableColumn, NSArrayController가, 콘텐츠 설정 정렬이

contentSet가 TableColumn의

이 두 개의 단일 컬럼 NSTableViews 와 SplitView 취급에 대한 데이터 소스와 같은 역할을하는 TableViews의 이름입니다 BookCategory 및 도서. 도서 표에는 book_titles이있는 단일 열이 있습니다. 클래스 BookCategory에는 예약 할 과 일대 다 관계가 있습니다.

BookCategory 테이블을 이용하여 부하에 정렬되어

@implementation MyBookCategoryController 

- (id)init 
{ 
    self = [super init]; 
    if (self) { 
     // Initialization code here. 
     NSSortDescriptor *descript = 
     [NSSortDescriptor sortDescriptorWithKey:@"name" 
        ascending:YES selector:@selector(caseInsensitiveCompare:)]; 

     [self setSortDescriptors:[[NSArray arrayWithObject:descript] autorelease] ]; 

    } 
    return self; 
} 

This same approach fails to sort the BookTitle table at load. !! 

The BookTitle table/column loads unsorted. 

For the TableColumn the Attributes Inspector has 
Sort Key:title 
Selector: caseInsensitiveCompare: 
Order: Ascending 

이 하나는 열 헤더 을 클릭 할 때 정렬을 가능하게 나타난다.

I want the data sorted when the view loads. 

The binding inspector for this book_title column has: 
Value : BookCategoryArrayController.arrangedObjects.name 

The BookTitleArrayController in binding inspector shows 
Content Set: Book Category ArrayController.selection.books 

문제, 부하가 정렬되지 않은 책 제목과 함께있는 tableview를 재 작성합니다. 사용자가 열 머리글을 처음 클릭 한 후에 만 ​​정렬됩니다.

예술, 역사, 스포츠의 세 가지 도서 카테고리가 있다고 가정 해보십시오. 응용 프로그램 인 splitview이 정렬에서 왼쪽 테이블, 를로드 할 때 는 :

Art 
History 
Sports 

사용자가 카테고리를 선택하고, 범주에있는 모든 책 에 대한 제목 오른쪽있는 tableView하지만 정렬되지 않은 나타납니다. 사용자가 book_title TableColumn의 머리글을 클릭하면 초기 정렬이 열에 대해 수행됩니다. 그 후 모든 북 카테고리를 선택하면 오른쪽 tableView에 book_titles의 정렬 된 디스플레이 이 표시됩니다. 즉, 첫 번째 카테고리 선택만으로 분류되지 않은 도서 제목 목록이 생성됩니다.

고마워 읽고, 마크

답변

0

이것은 마지막으로 나를 위해 일한의 개요입니다.

  Sorting with CategoryArrayController (NSArrayController) 

     Bindings Inspector 
     Content Set Bind to: CategoryArrayController.selection.books 

     SortDescriptors Bind to: ShareUserDefaultsController 
      Controller Key: values 
      sortDescriptors (note: exclamation point) 
      NSUnarchiveFromData 

    Shared User Defaults Controller 
     Referencing Outlets 
      userDefaultsController -- AppController (C:AppController) 
     Referencing Bindings 
      values.sortDescriptors -- Sort Descriptors Rx Array Controller (C:NSArrayController) 
            -- Sort Descriptors Category Array Controller (C:NSArrayController) 

     Clicking on Category Header does no sort. Selects all in Cats, and empties Recipe Table 
     Comments on the above welcome. 

    TableViewCat (NSTableController) 
     Attributes Inspector 
      TableView 
      Selection 
       Empty,Column,Type Select 
      Control 
      State.Enabled 
     Connections Inspec 
      None 
     Bindings Inspec 
      None 

     TableColumn -Category (NSTableColumn) 
     Attributes Inspec 
      Sort Key : None 
     Bindings Inspec 
      Value -- Category Array Controller.arrangedObjects.name 


    Sorting with RxArrayController (C:NSArrayController) 
     Attributes Inspec 
     Array Controller: 1-5 of 6 
     Object Controller 
      EntityName: Recipe 
      Prepares Content 
      Editable 
     Connections Inspector 
     Referencing Bindings 
      arrangedObjects.name -- Value - Table Column Recipe 
      selectedObjects  -- Double Click Argument - Table View Book 
     Bindings Inspector 
     Controller Content 
     Content Set 
      Category Array Controller.selection.books 
     Controller Content Parameters  
     Sort Descriptors Bind to: ShareUserDefaultsController 
      Controller Key: values 
      sortDescriptors (note: exclamation point) 
      NSUnarchiveFromData 
     Parameters 
      Managed Object Context(App Delegate.manangedObjectContext 

    TableView Book (NSTableView) 
     Attributes Inspector 
      TableView 
      Selection Empty,Column,Type Select 
      Control 
      State.Enabled 
     Connections Inspec 
      Bindings 
       DoubleClick Argument -- Book Array Controller.selectedObjects 
       Double Click Target -- App Delegate.self 
     Bindings Inspec 
      Double Click Argument (Book Array Controller.selectedObjects) 
      Double Click Target (App Delegate.self) 
       Bind To: App Delegate 
        Model Key Path: self (Repeats ?) 
        Selector Name: newBookAction: 
         Conditionally Sets Enabled 

     TableColumn - Book (NSTableColumn) 
     Attributes Inspec 
      Sort Key : None 
     Connections Inspec 
      Bindings 
       Value -- Book Array Controller.arrangedObjects.name 
     Bindings Inspec 
      Value -- Book Array Controller.arrangedObjects.name