有没有任何数据绑定机制可用于iOS? [英] Is there any data binding mechanism available for iOS?

查看:96
本文介绍了有没有任何数据绑定机制可用于iOS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在.NET中,我只是做类似DataForm.Source = Object然后魔法发生。平台将数据从ui文件更改为对象属性,验证等。我可以做类似Cocoa Touch和CoreData对象的东西吗?

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?

推荐答案

Cocoa最接近的是键值观察。在桌面Cocoa框架中,您可以使用绑定将用户界面元素挂钩到底层对象,以使对象或UI元素的更改反映在其他对象中。

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.

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

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:

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

这篇关于有没有任何数据绑定机制可用于iOS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆