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的数据绑定机制?
发布评论