Thursday, 15 August 2013

ios - Updating NSArray in Singleton -



ios - Updating NSArray in Singleton -

i have block, result contains nsarray called message. need access array in several uiviewcontrollers. utilize singletons, array not static, client can receive new message anytime, don't know possible update array within singleton? or reload in every view imported..

overall, i'm not sure how it. here's code, shows variable need utilize in other views. suggestions welcomed, easier solution without singletons best.

sampleviewcontroller.m:

pnchannel *my_channel = [pnchannel channelwithname:currentchannel.user shouldobservepresence:yes]; [pubnub requesthistoryforchannel:my_channel from:nil to:nil limit:100 reversehistory:no withcompletionblock:^(nsarray *message, pnchannel *channel, pndate *fromdate, pndate *todate, pnerror *error) { //i wanna access message array in other view controllers }];

i think singleton nice way this. other can utilize appdelegate property store value , can called in class [[[uiapplication sharedapplication] delegate] yoursharedproperty].in case using singleton appdelegate itself

ios objective-c objective-c-blocks

No comments:

Post a Comment