macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

bind:binding:withKeyPath:options:

バインドします
-(void)bind:(NSString *)binding:
             binding:(id)observableController:
             withKeyPath:(NSString *)keyPath:
             options:(NSDictionary *)options:

解説

バインドします。
【オプション】
●NSTableColumn
NSRaisesForNotApplicableKeys (NSNumber(BOOL))

返り値

( void )

なし

引数

( NSString * )binding

バインド名 IBのBindingsで三角矢印の右に表示されているもの

( id )observableController

コントローラ(NSControllerまたはそのサブクラス)

( NSString * )keyPath

Control key path+.+model key path
@”values.backgroundTextColor”
キーパス名
IBのBindingsでController Key+.+Model Key Pathをつなげたもの

( NSDictionary * )options

オプション
バインドによって変わる

フレームワーク

ApplicationKit

クラス

NSKeyValueBindingCreation

Instance Methods

使用可能

10.3

参照

-unbind:

例文

//sample1
//バインディングの設定テーブルコラムをdbArrayにバインドする
		[column_name bind:@"value"
				toObject:dbArray
				withKeyPath:[NSString stringWithFormat:@"arrangedObjects.%@",(NSString *)obj]
				options:[NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]	forKey:@"NSRaisesForNotApplicableKeys"]];

//sample2
NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
    [bindingOptions setObject:NSUnarchiveFromDataTransformerName forKey:@"NSValueTransformerName"];
    [textField bind: @"backgroundColor"
        toObject: [NSUserDefaultsController sharedUserDefaultsController]
        withKeyPath:@"values.backgroundTextColor"
        options:bindingOptions];