problem with Delegates..

Discussion in 'iPhone/iPad Programming' started by bytezone, May 5, 2009.

  1. macrumors member

    Joined:
    Apr 20, 2009
    #1
    I am using the Exploring Iphone SDK by Dave and Jeff.

    So far I am able to pick up everythin. But yesturday I came across a chapter which uses delegates like this...

    interface Control_FunViewController : UIViewController <UIActionSheetDelegate> {
    IBOutlet UITextField *nameField;
    IBOutlet UITextField *numberField;
    IBOutlet UILabel *sliderLabel;
    IBOutlet UISwitch *leftSwitch;
    IBOutlet UISwitch *rightSwitch;
    IBOutlet UIView *switchView;
    IBOutlet UIButton *doSomethingButton;


    }

    Where can read to know more about why <UIActionSheetDelegate> is used. I mean I want to learn more about delegates in cocoa touch frame work. Any good link for this...??

    Thanks
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    You are confusing two distinct and very different concepts: delegates and protocols. The <UIActionSheetDelegate> says that this class implements the UIActionSheetDelegate protocol.
     
  3. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    Delegates and delegations is an important and ubiquitous concept in Cocoa. Look here for some discussion:

    Cocoa Fundamentals Guide/Communication With Objects/Delegates and Data Sources.

    You should read the whole guide.

    I found this as follows: Open the Documentation window in Xcode. Type in 'delegation' to the search bar at the top of the window. Select Apple iPhone OS 2.2 Doc Set. Choose Full-Text search. A lot of choices appear but this is the best one.
     
  4. macrumors regular

    Joined:
    Apr 9, 2009
    #4
    yep, that's something completly different. if you want to know about protocols, that is pretty easy. it's just a way to make sure a class implements some methods. in your example, the protocol does not have any necessary methods, but some optional ones like

    actionSheet:clickedButtonAtIndex:

    to see everything a protocol defines see the reference for that protocol, like
    http://developer.apple.com/iphone/l...ctionSheetDelegate/UIActionSheetDelegate.html
     
  5. thread starter macrumors member

    Joined:
    Apr 20, 2009
    #5
    Sorry for the confusion..it should have been protocols.

    I read this
    http://developer.apple.com/DOCUMENT...#//apple_ref/doc/uid/TP30001163-CH15-BAJJABHJ

    It was very usefull. Thanks everyone for valuable suggestions.


     

Share This Page