• 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: Alex Zavatone <email@hidden>
  • Date: Tue, 26 Jan 2016 11:46:08 -0500

Shouldn't the notification be as dumb as possible and let the notification receiver/processor handle any decisions on what to process or read from?


On Jan 26, 2016, at 10:37 AM, Clark Cox wrote:

> The notification’s userInfo *must* be a dictionary, trying to force it to be something else is just asking for trouble. You could create a dictionary that contains your array of dictionaries if you want to be able to pass it through an NSNotification.
>
> That said, IMHO, this use of notifications has a little bit of code smell. Ideally, I would expect a notification to tell the control to reload/refresh/relayout itself by asking an appropriate delegate or controller for the data it needs (rather than getting the data out of the notification itself). It helps to have a strictly defined path that your data can follow; if it’s in an NSNotification, it could potentially have come from *anywhere*
>
> --
> Clark Smith Cox III
> email@hidden
>
>> On Jan 26, 2016, at 07: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?
>> _______________________________________________
>>
>> 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
>
>
> _______________________________________________
>
> 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


_______________________________________________

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>)
 >Re: Array of Dictionaries as .userInfo (From: Clark Cox <email@hidden>)

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