• 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: Using Delegation in communicating data between two controllers....
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using Delegation in communicating data between two controllers....


  • Subject: Re: Using Delegation in communicating data between two controllers....
  • From: Evan M <email@hidden>
  • Date: Tue, 18 Aug 2009 11:53:35 -0400

Ric,

There is a very good tutorial from Cocoa Dev Central regarding delegates: http://cocoadevcentral.com/articles/000075.php

And from that article there is a link to another good article as well:
http://www.stepwise.com/Articles/Technical/2000-03-03.01.html

As mentioned in the articles, delegates are used for notification of events that are about to happen. The prospect of "sharing data between controllers" doesn't sound like a good design. The model(s) in your application should handle the storage and access of the data, your controllers will interact with the model in order to read or modify that data. You may have more than one controller accessing the same model, but various controllers don't necessarily send data back and forth between each other, they can send messages to other controllers and their views though.

--
Evan

On Aug 14, 2009, at 5:24 PM, Frederick C. Lee wrote:

Environment: iPhone (but Cocoa as well)... I was using the App Delegate
as the link amongst view controllers in sharing data. The 'App Delegate',
being persistent,
was my 'global data' clearing house.


But now I learned that this is frown upon. The preferred way is using
delegation to share data.


From what I've read, delegation is essentially shared procedures via an
informal protocol; albeit the preferred design is to use
the formal protocol with @optional & @required directives.

I think I understand the basics.

But I wonder, how is data actually SHARED between a view controller and its
delegate?


The view controller has an ivar of type 'id' for the delegate, which has
methods declared within the protocol.


Here's some elementary questions:
1) How is the delegate actually launched (with valued parameters)?
2) How does the calling controller receive data back from the delegate?


Regards,
Ric.
_______________________________________________

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


References: 
 >Using Delegation in communicating data between two controllers.... (From: "Frederick C. Lee" <email@hidden>)

  • Prev by Date: Re: Newbie query re multithreading
  • Next by Date: Re: Mac access to iPhone Document Directory
  • Previous by thread: Using Delegation in communicating data between two controllers....
  • Next by thread: Apple Event parameter types in Cocoa scripting
  • Index(es):
    • Date
    • Thread