Amazon.com Widgets Confusing about the self and the super...
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 22, 2013, 05:14:51 AM
Home Help Search chat Login Register   
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+  Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+  Old Stuff
| |-+  Chapter Study
| | |-+  Chapter 7 - More on Classes
| | | |-+  Confusing about the self and the super...
Pages: [1]   Go Down
Print
Author Topic: Confusing about the self and the super...  (Read 630 times)
diuming
Newbie
*
Posts: 8


Email




« on: September 20, 2010, 08:02:24 PM »

hi everyone,

I confuse about the self keyword in Objective-C, What kind of the method(instance method or class method) can let self to invoke? also the super keyword have same problem.

thanks all.
Logged
skochan
Administrator
Hero Member
*****
Posts: 3103







« Reply #1 on: September 21, 2010, 09:06:13 PM »

Did you read the description of these in the text?   self refers to the receiver of the method, and it provides a way to reference that object, for example in order to send it another message from within the method.   

super refers to the parent class of the current object, and provides a way to execute a method that you may have overridden in the current class.   I suggest you go back to the text, as a more detailed reading is required.

Cheers,

Steve
Logged
diuming
Newbie
*
Posts: 8


Email




« Reply #2 on: September 23, 2010, 08:56:12 AM »

Thanks Steve,

I know them about your described self and super, But my question please refer to following :

//------------  classMethod -----------------------
+ (id)classMethod {
         id  obj = [[self alloc] init];
         return obj;
}

//----------- instanceMethod --------------------
- (id)instanceMethod {
        id obj = [self init];
        return boj;
}

The class method can only invoke super's class method whether this concept is correct?
Sorry!! My english not very well.

Diuming

Logged
Pages: [1]   Go Up
Print
Jump to:  



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.