• 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: NSTreeController selection and Swift
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTreeController selection and Swift


  • Subject: Re: NSTreeController selection and Swift
  • From: Rick Mann <email@hidden>
  • Date: Tue, 24 May 2016 18:01:21 -0700

> On May 24, 2016, at 17:58 , Quincey Morris <email@hidden> wrote:
>
> On May 24, 2016, at 17:49 , Rick Mann <email@hidden> wrote:
>>
>> I'm trying to observe an NSTreeController's selection property, and then do something with that selection when it changes. But Swift doesn't just let me treat .selection as my object type (the way Obj-C would). So, can I use it (short of calling -valueForKey:) from Swift?
>
> ’treeController.selection' is of type AnyObject, but it can be a marker object (no selection or multiple selection or …) OR one of your objects. So to get your object, use:
>
> 	if let myObject = treeController.selection as? MyObject {
> 		// do whatever if an object is selected
> 	}
>
> Is that what you want?

That's what I tried, but .selection is always _NSControllerObjectProxy, and the resulting conditional cast never triggers.


--
Rick Mann
email@hidden



_______________________________________________

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: NSTreeController selection and Swift
      • From: Quincey Morris <email@hidden>
References: 
 >NSTreeController selection and Swift (From: Rick Mann <email@hidden>)
 >Re: NSTreeController selection and Swift (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: NSTreeController selection and Swift
  • Next by Date: Re: NSTreeController selection and Swift
  • Previous by thread: Re: NSTreeController selection and Swift
  • Next by thread: Re: NSTreeController selection and Swift
  • Index(es):
    • Date
    • Thread