是否有适用于iOS的数据绑定机制?

编程入门 行业动态 更新时间:2024-10-26 14:29:27
本文介绍了是否有适用于iOS的数据绑定机制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 在.NET中,我只是像DataForm.Source = Object这样做,然后发生魔法。平台将数据从ui文件更改为对象属性,进行验证等。可以用Cocoa Touch和CoreData对象做类似的事情吗?

解决方案

Cocoa中最接近的是Key-Value Observing。在桌面Cocoa框架中,您可以使用绑定将用户界面元素挂接到底层对象,以便对象或UI元素中的更改反映在另一个对象中。

可可在iOS上没有这种UI绑定,您仍然可以使用键值观察将数据模型中的更改与UI元素进行同步,如下所述:

developer.apple /library/iOS/#documentation/General/Conceptual/Devpedia-CocoaApp/KVO.html

In .NET I just do something like DataForm.Source = Object and then magic happens. Platform routes data changes from ui fileds to object properties, does validation and so on. Can I do something similar with Cocoa Touch and CoreData objects?

解决方案

The closest thing in Cocoa is 'Key-Value Observing'. In the desktop Cocoa framework you can use bindings to hook user interface elements up to underlying objects so that changes in the objects or UI elements are reflected in the other.

Whilst Cocoa on iOS doesn't have this sort of UI bindings, you can still use 'Key-Value Observing' to synchronise changes in the data model with UI elements as described here:

developer.apple/library/iOS/#documentation/General/Conceptual/Devpedia-CocoaApp/KVO.html

更多推荐

是否有适用于iOS的数据绑定机制?

本文发布于:2023-11-27 08:44:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637335.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:适用于   绑定   机制   数据   iOS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!