On Tue, Jan 6, 2009 at 8:12 PM, Keary Suska <[email protected]>wrote:
> > On Jan 6, 2009, at 11:14 AM, Mohan Parthasarathy wrote: > > Let us say that there are two objects A and B. >> >> 1) Object A produces some data >> 2) Object B consumes the data produced by object A >> >> When object B sends a message to object A for fetching the data, the data >> is >> not available immediately. When the data arrives later, it needs to notify >> object B. >> >> For example, object A fetches data from some web service and Object B is >> some sort of a "controller". How does one handle this in Cocoa ? >> >> - I can include the functionality of Object A within Object B itself and >> hence there is no issue. But i guess this is prohibited as per the MVC >> design. >> - Object A can retain object B and later send the message back when data >> is >> available. But then this creates a dependency of object B knowing object >> A >> and object A knowing object B. Is this okay ? >> - Any other way ? >> > > > NSNotificationCenter? Object Delegation Pattern < > http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaFundamentals/CommunicatingWithObjects/chapter_6_section_4.html#//apple_ref/doc/uid/TP40002974-CH7-SW26> > ? Key-Value Observation? > Thanks for your response. I did look at Delegation but perhaps confused because i thought object A also has to know about object B which i guess is not needed. Is the following right understanding ? object A has a method: -(void)fetchData:(id)sender and also looks for a delegate in object B: [sender respondsToSelector:@DataReady] object B sends a message to object A: fetchData:(id)self and implements DataReady This way object A need not know anything about object B i guess. Isn't Notification mechanism used for one-to-many ? Thanks mohan > > HTH, > > Keary Suska > Esoteritech, Inc. > "Demystifying technology for your home or business" > > _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
