0

::編集 - 解決済み.. NSComboBoxDataSource に適切に準拠していませんでした..

私は動作する NSComboBox 実装を持っています - ただし、データ ソースが変更された場合、変更はアプリが再起動されるまでコンボ ボックスに反映されません。ところどころ塗りましたが[myComboBox reloadData]、これでは効果がありません。私が探すべきアイデアはありますか?

データ ソースは IB でマークされています。

次のデータ ソース メソッドが実装されています。

- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)categoryCombo{


    //NSLog(@"categoryMutableArray count: %lu", (unsigned long)categoryMutableArray.count);
    return categoryMutableArray.count;
}


- (id)comboBox:(NSComboBox *)categoryCombo objectValueForItemAtIndex:(NSInteger)row {
    //NSLog(@"%s", __FUNCTION__);

    [self refreshCategories:nil];

    currentCategory  = [categoryMutableArray objectAtIndex:row];
    mainCategory.stringValue = [currentCategory valueForKey:@"catName"];

    return mainCategory.stringValue;

}


- (void)comboBoxSelectionDidChange:(NSNotification *)notification {
    //NSLog(@"%s", __FUNCTION__);

    currentItem = [mainMutableArray objectAtIndex:rowNumber];

    //[self.mainCategory setStringValue:
    // [NSString stringWithFormat: @"%@", [categoryMutableArray objectAtIndex: [(NSComboBox *)[notification object] indexOfSelectedItem]]]];

    currentCategory = [categoryMutableArray objectAtIndex: [(NSComboBox *)[notification object] indexOfSelectedItem]];
    NSString *newCatString = [currentCategory valueForKey:@"catName"];

    [currentItem setObject:newCatString forKey:@"category"];
    [currentItem saveInBackground];

    //NSLog(@"new category name may be: %@",[currentDream valueForKey:@"category"]);
}
4

0 に答える 0