Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 以编程方式加载带有键/值(或绑定?)的NSCOMBOX_Objective C_Xcode_Cocoa Bindings_Nscombobox - Fatal编程技术网

Objective c 以编程方式加载带有键/值(或绑定?)的NSCOMBOX

Objective c 以编程方式加载带有键/值(或绑定?)的NSCOMBOX,objective-c,xcode,cocoa-bindings,nscombobox,Objective C,Xcode,Cocoa Bindings,Nscombobox,我有一个sqlite3数据库加载了一个已访问的,我正试图将下表的内容放入一个NSCOMBOX(然后根据其他操作参数自动选择默认键)。以下是表格内容: (table) _backup_increment: ('incrementid', 'value', 'description') (1, 'h', 'hours') (2, 'd', 'days') (3, 'w', 'weeks') (4, 'm', 'months') (5, 'y', 'years') 目标是以某种方式(理想情况下是在代

我有一个sqlite3数据库加载了一个已访问的,我正试图将下表的内容放入一个NSCOMBOX(然后根据其他操作参数自动选择默认键)。以下是表格内容:

(table) _backup_increment:
('incrementid', 'value', 'description')
(1, 'h', 'hours')
(2, 'd', 'days')
(3, 'w', 'weeks')
(4, 'm', 'months')
(5, 'y', 'years')
目标是以某种方式(理想情况下是在代码中,但如果必须,或者如果认为这是一种更好的做法,则使用绑定)将这些项加载到NSComboBox中,如下所示:

      _______________________
key:  [ (Select Value)   |\/]
      -----------------------
key:1 | h (hours)           |
key:2 | d (days)            |
key:3 | w (weeks)           | (* auto select this one as the default for now)
key:4 | m (months)          |
key:5 | y (years)           |
      -----------------------
我在某个时候创建了一个BackupIncrement类,其中有3个公开的实例变量作为incrementid、value和description的属性。我打算加载一个NSMutableArray并尝试通过编程将其链接为数据源,但我似乎无法让它工作。这是我到目前为止的代码,您可以看到我一直在使用对象和可变数组:

-(void)doAddItemsTocmbDefaultBackupIncrement {
    const char* chrSQLSelect = "SELECT * FROM _backup_increments";
    sqlite3_stmt* compiledSQL;
    if (sqlite3_prepare_v2(claAppDelegate.sl3Database, chrSQLSelect, -1, &compiledSQL, NULL) == SQLITE_OK) {
        while (sqlite3_step(compiledSQL) == SQLITE_ROW) {
            BackupIncrement* bi = [[BackupIncrement alloc]
                                initWithintIncrementId:[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledSQL, 0)]
                                AndstrIncrementValue:[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledSQL, 1)]
                                AndstrIncrementDescription:[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledSQL, 2)]];
            //[cmbDefaultBackupIncrement addItemWithObjectValue:[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledSQL, 1)]];
            [cmbDefaultBackupIncrement addItemWithObjectValue:bi];
            [marBackupIncrement addObject:bi];
//          NSLog(@"%ld: %@(%@)",
//                  (long)[[NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledSQL, 0)] integerValue],
//                  [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledSQL, 1)],
//                  [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledSQL, 2)]);
//          NSLog(@"===========");
        }
        for (id obj in marBackupIncrement)
            NSLog(@"obj: %@", [obj valueForKey:@"intIncrementId"]);
        [cmbDefaultBackupIncrement reloadData];
        //NSLog(@"What? %@", marBackupIncrement);
    }
}

所以,是的,如果您能通过编程或使用XCode5中的绑定来帮助我们,我们将不胜感激!谢谢

我发现我的问题最终是时间问题。我最终切换到了一个NSpoupButton,但我的最终结果是: