jonsibley jonsibley - 1 year ago 90
Swift Question

Is key-value observation (KVO) available in Swift?

If so, are there any key differences that weren't otherwise present when using key-value observation in Objective-C?

Answer Source

Yes and no. KVO works on NSObject subclasses much as it always has. It does not work for classes that don't subclass NSObject. Swift does not (currently at least) have its own native observation system.

(See comments for how to expose other properties as ObjC so KVO works on them)

See the Apple Documentation for a full example.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download