What is defined by "receiver" in CALAyer addSublayer

Discussion in 'iOS Programming' started by samhasi, Mar 27, 2011.

  1. samhasi macrumors newbie

    Joined:
    Mar 3, 2011
    #1
    Hi all,
    I'm bit confused here. What is the meaning of "receiver" in addSublayer method in CALayer. Is it the same as the superLayer????
    any help would be appriciated:)

    thanks.
     
  2. admanimal macrumors 68040

    Joined:
    Apr 22, 2005
    #2
    "Receiver" always refers to the object you are sending the message to. So layer is the receiver in the following piece of code:

    Code:
    [layer addSublayer:otherLayer];
    
    In this specific case, the receiver is the layer that you are adding the sublayer to.
     
  3. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #3
    The "receiver" is the same as it is for every other object. It is the object that you are communicating with. In this case using the method addSublayer:.

    Experiment to see what superlayer is?

    Code:
    CALayer * layer1 = [CALayer layer];
    CALayer * layer2 = [CALayer layer];
    [layer2 addSublayer: layer1];  // layer2 is the receiver
    NSLog(@"layer1 objectid: %@", layer1);
    NSLog(@"layer2 objectid: %@", layer2);
    NSLog(@"layer1.superlayer objectid: %@",layer1.superlayer);
    
     

Share This Page