• 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: Array of Dictionaries as .userInfo
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Array of Dictionaries as .userInfo


  • Subject: Re: Array of Dictionaries as .userInfo
  • From: Roland King <email@hidden>
  • Date: Tue, 26 Jan 2016 23:30:29 +0800

> On 26 Jan 2016, at 23:12, Eric E. Dolecki <email@hidden> wrote:
>
> I have a control which takes an array of dictionaries to construct it's UI
> (as a distinct method).
>
> Now I'd like to add a notification to supply the data as well. I'd like to
> pass the data as userInfo.
>
> When constructing the observer method, how do I constuct?
>
> func weHaveData(notification:NSNoticiation){
>   let dict = notification.userInfo as Array<Dictionary<String,String>>
>   control.loadData(dict)
> }
>
> *Can't convert value of type [NSObject:AnyObject]? to
> Array<Dictionary<String,String>> in coercion*
>
> I've tried without the cast. Is there an easy work around?
> _______________________________________________


the userInfo of an NSNotification is an NSDictionary, so of course you can’t cast it to an Array. There’s no workaround, they aren’t the same thing at all.

If you want to pass an Array of Dictionaries in the userInfo, you need to put it in the userInfo *dictionary* under a key, then retrieve it, then cast it.
_______________________________________________

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: Array of Dictionaries as .userInfo
      • From: "Eric E. Dolecki" <email@hidden>
References: 
 >Array of Dictionaries as .userInfo (From: "Eric E. Dolecki" <email@hidden>)

  • Prev by Date: Array of Dictionaries as .userInfo
  • Next by Date: Re: Array of Dictionaries as .userInfo
  • Previous by thread: Array of Dictionaries as .userInfo
  • Next by thread: Re: Array of Dictionaries as .userInfo
  • Index(es):
    • Date
    • Thread