在这里,我使用NSArrayController
将Core Data实体的属性绑定到文本视图表单元格的值。
我使用什么语法在模型密钥路径中访问实体的多个属性?
格式字符串示例:@"%@, %@", lastName, firstName;
答案 0 :(得分:3)
在文本字段的绑定检查器中:
selection
lastName
%{value1}@, %{value2}@
selection
,firstName
NSTextField section of the Cocoa Bindings Reference.
中记录了这一点为了完整性,这里有一些我自己的代码,我以编程方式进行这种绑定:
NSString* bannerPattern = @": %{value1}@ items found, %{value2}@ hidden %{value3}@";
NSString* totalPattern = [dateString stringByAppendingString:bannerPattern];
[ftview.textField bind:@"displayPatternValue1" toObject:ft withKeyPath:@"visibleNumber" options:@{NSDisplayPatternBindingOption : totalPattern}];
[ftview.textField bind:@"displayPatternValue2" toObject:ft withKeyPath:@"hiddenNumber" options:@{NSDisplayPatternBindingOption : totalPattern}];
[ftview.textField bind:@"displayPatternValue3" toObject:ft withKeyPath:@"newString" options:@{NSDisplayPatternBindingOption : totalPattern}];