objective c - Reactive NSMutableDictionary? -


how subscribe objects being added , removed nsmutabledictionary using reactivecocoa? also, i'd broadcast notification when changes. guess broadcasting can done using racmulticastconnection how tie dictionary change? i'm trying use reactivecocoa first time in project , stuck on first thing wanted :(

racobserve wrapper around key-value observing, , inherits same features , flaws.

unfortunately, nsmutabledictionary not automatically observable. there 2 ways work around that:

  1. subclass , add kvo support.
  2. create real model object, properties instead of dictionary keys. you'll kvo on properties, long use setters instead of direct ivar modification.

i'm not sure mean "[broadcasting] notification when changes," or why it'd valuable. notifications way global taste, , i'd promote using more limited observation instead (like kvo).

however, assuming want this, it's simple enough post notification in response new signal value:

@weakify(self); [racobserve(self, dictionary) subscribenext:^(nsdictionary *dictionaryvalue) {     @strongify(self);     [nsnotificationcenter.defaultcenter postnotificationname:somenotificationname object:self]; }]; 

if want kvo's change dictionary (which includes information added/removed values), you'll need replace racobserve +rac_valuesandchangesforkeypath:options:observer:.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -