What is defined by "receiver" in CALAyer addSublayer

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

  1. samhasi macrumors newbie

    Mar 3, 2011
    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:)

  2. admanimal macrumors 68040

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

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

    Jan 28, 2003
    Less lost in L.A.
    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?

    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