首页 \ 问答 \ 将NSTableView填充并绑定到多个阵列控制器(Populate and bind an NSTableView to multiple array controllers)

将NSTableView填充并绑定到多个阵列控制器(Populate and bind an NSTableView to multiple array controllers)

我有一个API提供NSArray与一堆内容对象 - 我们称之为likedFruit - 和一个名为likedFruit的空NSMutableArray。

我为两个数组创建了NSArrayControllers,并将我的TableView绑定到acquireFruit.arrangedObjects。 tableView的第一列绑定到arrangeObjects.name并正确显示所有美味的水果。

我创建了第二个带有复选框的列 - 当用户填充框时,我想将水果添加到我的likedFruit数组中。 取消选中该框应该从likedFruit数组中删除fruit对象。

基本上我想让我的NSTableView加入两个阵列控制器之间。 我有一种感觉,我应该为此制作一个单独的控制器,但我不确定如何解决问题。

我还应该提一下,我知道我可以遍历我的数组并使用我需要的字段构建另一个对象,但我的目标是通过使用绑定来实现,如果可能的话。

思考?


I have an API provided NSArray with a bunch of content objects – we'll call this acquiredFruit – and an empty NSMutableArray called likedFruit.

I've created NSArrayControllers for both arrays and bound my TableView to acquiredFruit.arrangedObjects. The first column of the tableView is bound to arrangedObjects.name and correctly shows all the delicious fruit.

I've created a second column with a checkbox – when the user fills the box I'd like to add the fruit to my likedFruit array. Unchecking the box should remove the fruit object from the likedFruit array.

Essentially I'd like my NSTableView to join between two array controllers. I have a feeling I should be making a single separate controller for this, but I'm unsure how to approach the problem.

I should also mention that I'm aware I could iterate through my array and construct another object with the fields I need, but my goal is to do this by using bindings, if possible.

Thoughts?


原文:https://stackoverflow.com/questions/11714659
更新时间:2022-06-19 15:06

最满意答案

它仍然存在,因为您使用maptypecontrol而不是mapTypeControl

JavaScript是一种区分大小写的语言:关键字,函数名称,变量,标识符......所有内容都区分大小写,因此maptypecontrolmapTypeControl不同。 并且因为mapTypeControl不存在,所以使用默认值true


It is still there because you used maptypecontrol instead of mapTypeControl.

JavaScript is a case sensitive language: keywords, function names, variables, identifiers... everything is case sensitive so maptypecontrol is different from mapTypeControl. And because mapTypeControl is not there, default value true is used.

相关问答

更多
  • 这绝对是您与代码一起使用的CSS问题。 寻找适用于所有图像的CSS,如: img { max-width: 100%; } That is definitely a CSS issue that you have with your code. Look for CSS that is applying to all images like: img { max-width: 100%; }
  • 您可以使用以下命令测试每个active属性是否为真: var arr = [ {type: "Benzine", active: false}, {type: "Diesel", active: false}, {type: "Electricity", active: false} ] console.log(arr.every(obj => obj.active)); var arr = [ {type: ...
  • 你可以调用GetClassName即 // given controlHwnd passed to me TCHAR controlClassName[128]; GetClassName(controlHwnd,controlClassName,128); 然后,你必须做一堆字符串比较基于字符串,即“按钮” - 所以不是很好,但应该工作。 You could call GetClassName i.e // given controlHwnd passed to me TCHAR controlCla ...
  • 更新 :如评论中所述,您必须使用for循环,因为cm.config.users是一个数组。 var isFromUser = false; for(var i = 0; i < cm.config.users.length; i++) { isFromUser = contains(cm.config.users[i], username, 'exists'); if(isFromUser) break; } 该功能正在按预期工作,没有任何问题。 当我运行与cm.config.users: 2 ...
  • if( translate ) { if( [translate boolValue] ) { // translate is present and is set (YES) } else { // translate is present and is not set (NO) } } else { // translate is nil / not present } 如果您希望将此外观更像是一个三向分支: if( [translate boolValue] ) { ...
  • 有一个已知问题,其中设置地图样式将新样式与旧样式合并,而不是完全覆盖它。 该团队计划解决这个问题。 同时,如果您处理当前地图并使用地图样式创建地图的新实例,则它将按预期工作。 There is a known issue where setting the map style merges the new style with the old style instead of overwriting it completely. The team plans to fix this. In the mean ...
  • 它仍然存在,因为您使用maptypecontrol而不是mapTypeControl 。 JavaScript是一种区分大小写的语言:关键字,函数名称,变量,标识符......所有内容都区分大小写,因此maptypecontrol与mapTypeControl不同。 并且因为mapTypeControl不存在,所以使用默认值true 。 It is still there because you used maptypecontrol instead of mapTypeControl. JavaScrip ...
  • 因为您的input是类型number任何非数字值都将被解释为空字符串。 因此,您最终得到一个空字符串,然后将其传递给isNaN 。 那么会发生什么? 请参阅规范中的isNaN : 如果ToNumber( number )是NaN,则返回true。 否则,返回false。 因此,使用空字符串调用“ToNumber”。 当对其应用“ToNumber”操作时,空字符串强制为0 ,而0不是NaN 。 请参阅规范中应用于字符串类型的ToNumber : StringNumericLiteral ::: [empty] ...
  • 没有一个是关闭的原因是因为当按下鼠标按钮然后释放鼠标按钮时会调用MouseClicked,换句话说,它是鼠标按下事件,然后是鼠标释放事件。 如果你需要知道触发它的是什么,请查看event.getButton()并查看它是否是任何MouseButton 。 尝试将代码更改为以下内容: hb.addEventHandler(MouseEvent.MOUSE_CLICKED, event -> { System.out.println("Middle Clicked?" + event.getButton ...
  • 检查您的HTML
    在你的jquery中,你正在引用它 if ($('#provinsi').val()=='') 您的ID不匹配。 P应该是jquery中的大写或HTML中的小。 jQuery区分大小写 Check your HTML

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)