• 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: Aggravation trying to implement NSValueTransformer subclasses in Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Aggravation trying to implement NSValueTransformer subclasses in Swift


  • Subject: Re: Aggravation trying to implement NSValueTransformer subclasses in Swift
  • From: Quincey Morris <email@hidden>
  • Date: Tue, 12 May 2015 22:57:57 +0000

On May 12, 2015, at 15:38 , Quincey Morris <email@hidden> wrote:
>
> dynamic var message: String
> dynamic var messageIsEmpty: Bool {return String == “”}
> static var keyPathsForValuesAffectingMessageIsEmpty: NSSet {return NSSet (object: "messageIsEmpty”)}

FWIW, a Swift-ier way to do this might be something like:

	dynamic var message: String = "" {
		didSet {messageIsEmpty = message == ""}
	}
	private(set) dynamic var messageIsEmpty: Bool = true

This is at the cost of actually storing the derived property value, though that’s not likely to be a problem in window controller.

(Again, not tested.)



_______________________________________________

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


References: 
 >Aggravation trying to implement NSValueTransformer subclasses in Swift (From: William Squires <email@hidden>)
 >Re: Aggravation trying to implement NSValueTransformer subclasses in Swift (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Aggravation trying to implement NSValueTransformer subclasses in Swift
  • Next by Date: Re: IB_DESIGNABLE - anyone got it to work?
  • Previous by thread: Re: Aggravation trying to implement NSValueTransformer subclasses in Swift
  • Next by thread: Re: Aggravation trying to implement NSValueTransformer subclasses in Swift
  • Index(es):
    • Date
    • Thread