• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Bindings in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bindings in Swift


  • Subject: Re: Bindings in Swift
  • From: Quincey Morris <email@hidden>
  • Date: Sat, 09 Aug 2014 18:44:23 -0700

On Aug 9, 2014, at 18:13 , Roland King <email@hidden> wrote:

> If this is where we are then it would be handy to have the runtime throw, or at least log, if you attempt to KVO a Swift property which isn't dynamic.

Yes, though I expect (hope?) that there is eventually something better than traditional KVO/bindings/etc coming along for Swift. (Note, for example, that did/willSet takes over a little bit of the KVO universe. Just not very much.)

> If I have understood properly, up until beta 4 that also used objc_MsgSend and was fully dynamic, as of beta 5 it may or may not use objc_MsgSend or it may optimize around it.

I got the impression that earlier betas might have optimized around it, and therefore that KVO wasn’t reliable. I think ‘dynamic’ is a bug fix.

> if you write such a property in Swift and mark it only @objc then it's quite possible Swift will call the original, unswizzled methods, and you won't get your notification .. because objc_MsgSend may not be used

Yes, I suppose if Swift decided to use a direct call, it would call the wrong thing, but not because of swizzling, since KVO doesn’t swizzle. Instead, it dynamically changes the class of your object to a synthetic class with a method that overrides your setter. So, the error in Swift’s “reasoning” would be that the method wasn’t overridden when it really was.




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Bindings in Swift
      • From: Charles Srstka <email@hidden>
    • Re: Bindings in Swift
      • From: Roland King <email@hidden>
References: 
 >Re: Bindings in Swift (From: Quincey Morris <email@hidden>)
 >Re: Bindings in Swift (From: Roland King <email@hidden>)

  • Prev by Date: Re: Bindings in Swift
  • Next by Date: Re: True Type Fonts
  • Previous by thread: Re: Bindings in Swift
  • Next by thread: Re: Bindings in Swift
  • Index(es):
    • Date
    • Thread