Objective C Constructor

Discussion in 'Mac Programming' started by satyam90, Oct 25, 2007.

  1. macrumors regular

    satyam90

    Joined:
    Jul 30, 2007
    Location:
    Bangalore, India
    #1
    What is the difference between init, initialize and awakeFromNib functions. All all are similar to constructors.
     
  2. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    You seem to have forgotten the + and - signs in front of the methods names:

    +initialize initialises a Class (not an instance)

    -init initialises and instance

    -awakeFromNib initialises a de-serialised instance being created from a nib.

    The last two are different as in the latter you can be sure any outlets connected in the nib are connects but this is not true in the former.
     
  3. thread starter macrumors regular

    satyam90

    Joined:
    Jul 30, 2007
    Location:
    Bangalore, India
    #3
    I didn't understand what do u mean by "you can be sure any outlets connected in the nib are connects" in your response
     
  4. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    Exactly what I said. If you create an instance of this object in nib file then any outlets will not be connected when init gets called but will be when awakeFromNib is called.
     
  5. Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #5

Share This Page