Skip navigation.
 
mlRe: Trying to understand -- please help...
FROM : Sherm Pendley
DATE : Wed May 21 22:52:17 2008

On Wed, May 21, 2008 at 3:14 PM, Vijay Malhan <vijay.<email_removed>>
wrote:

> Thanks for the pointers to the documentation. This is sample snippet from
> the documentation.
>
> @implementation MyClass
>
> + (void)initialize
>
> {
>
>    if ( self == [MyClass class] ) {
>
>        /* put initialization code here */
>
>    }
>
> }
>
>
> If I'm not wrong "self" equivalent of "this" which points to an instance
> var.



In a class method, self points to the class object, not to an instance.


> And it is initialized in - init (instance)method.



That makes no sense at all. +initialize a class method, not an instance
method, and it's guaranteed to be called before any other method.


> initialize, it's nil. So does "self" even exist when + initialize is
> called.
> Cuz as per documentation it is the first method called for a Class, before
> +alloc and -init methods are called.
>
> Or the comparison condition in above example is not valid.



The above comparison simply checks "self" against a specific Class object,
so that this +initialize won't have any effect in subclasses.

Once again - you seriously need to take a step back and review the
fundamentals docs. It's a dead-end to try to learn by skipping the
fundamentals, going straight to the references and thinking in terms of
equivalent constructs in Java, C++, or whatever. You need to approach and
learn Cocoa on its own terms.

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net

Related mailsAuthorDate
mlTrying to understand -- please help... john darnell May 21, 18:05
mlRe: Trying to understand -- please help... Torsten Curdt May 21, 18:13
mlRe: Trying to understand -- please help... Vijay Malhan May 21, 18:16
mlRe: Trying to understand -- please help... Paul Bailey May 21, 18:20
mlRe: Trying to understand -- please help... Hank Heijink (Mail… May 21, 18:28
mlRe: Trying to understand -- please help... João Pavão May 21, 18:29
mlRe: Trying to understand -- please help... Gérard Iglesias May 21, 18:34
mlRE: Trying to understand -- please help... john darnell May 21, 18:41
mlTrying to understand -- please help... Peter Hudson May 21, 18:47
mlRe: Trying to understand -- please help... Gérard Iglesias May 21, 18:49
mlRe: Trying to understand -- please help... Clark Cox May 21, 19:03
mlRe: Trying to understand -- please help... Gérard Iglesias May 21, 19:11
mlRe: Trying to understand -- please help... Shawn Erickson May 21, 19:17
mlRe: Trying to understand -- please help... Bill Bumgarner May 21, 19:21
mlRe: Trying to understand -- please help... Hank Heijink (Mail… May 21, 19:25
mlRe: Trying to understand -- please help... Shawn Erickson May 21, 19:32
mlRe: Trying to understand -- please help... Sherm Pendley May 21, 19:36
mlRe: Trying to understand -- please help... Shawn Erickson May 21, 19:38
mlRe: Trying to understand -- please help... Ilan Volow May 21, 19:40
mlRe: Trying to understand -- please help... I. Savant May 21, 20:05
mlRe: Trying to understand -- please help... I. Savant May 21, 20:07
mlTrying to understand -- please help... Johnny Lundy May 21, 20:35
mlRe: Trying to understand -- please help... Shawn Erickson May 21, 20:45
mlRe: Trying to understand -- please help... Vijay Malhan May 21, 20:47
mlRe: Trying to understand -- please help... Bill Bumgarner May 21, 20:48
mlRe: Trying to understand -- please help... Shawn Erickson May 21, 20:54
mlRe: Trying to understand -- please help... I. Savant May 21, 20:57
mlRe: Trying to understand -- please help... Shawn Erickson May 21, 21:00
mlRe: Trying to understand -- please help... I. Savant May 21, 21:00
ml+initialize (was Re: Trying to understand -- please help...) Jason Stephenson May 21, 21:00
mlRe: Trying to understand -- please help... Michael Vannorsdel May 21, 21:07
mlRe: Trying to understand -- please help... Ilan Volow May 21, 21:08
mlRe: Trying to understand -- please help... Vijay Malhan May 21, 21:14
mlRe: Trying to understand -- please help... Shawn Erickson May 21, 21:24
mlTrying to understand -- please help... Johnny Lundy May 21, 21:37
mlRe: Trying to understand -- please help... Andy Lee May 21, 21:41
mlRe: Trying to understand -- please help... Jeff LaMarche May 21, 21:58
mlRe: Trying to understand -- please help... Sherm Pendley May 21, 22:07
mlRe: Trying to understand -- please help... Sherm Pendley May 21, 22:20
mlRe: Trying to understand -- please help... Uli Kusterer May 21, 22:33
mlRe: Trying to understand -- please help... Sherm Pendley May 21, 22:37
mlRe: Trying to understand -- please help... Uli Kusterer May 21, 22:45
mlRe: Trying to understand -- please help... Sherm Pendley May 21, 22:52
mlRe: Trying to understand -- please help... Christopher Nebel May 21, 23:06
mlRe: Trying to understand -- please help... Hamish Allan May 21, 23:09
mlRe: Trying to understand -- please help... Sherm Pendley May 21, 23:15
mlRe: Trying to understand -- please help... Ken Thomases May 21, 23:28
mlRe: Trying to understand -- please help... Sherm Pendley May 21, 23:29
mlRe: Trying to understand -- please help... Andy Lee May 22, 01:18
mlRe: Trying to understand -- please help... Jens Alfke May 22, 04:23
mlRe: Trying to understand -- please help... Jens Alfke May 22, 04:30
mlRe: Trying to understand -- please help... Jens Alfke May 22, 04:37
mlRe: Trying to understand -- please help... Michael Vannorsdel May 22, 04:55
mlRE: Trying to understand -- please help... Caleb Strockbine May 22, 16:27
mlRe: Trying to understand -- please help... Greg Titus May 22, 17:43
mlRe: Trying to understand -- please help... glenn andreas May 22, 18:25
mlRe: Trying to understand -- please help... Andy Lee May 22, 22:08
mlRe: Trying to understand -- please help... Andy Lee May 22, 22:15
mlRe: Trying to understand -- please help... Joseph Kelly May 22, 22:16
mlRe: Trying to understand -- please help... Johnny Lundy May 22, 23:13
mlRe: Trying to understand -- please help... glenn andreas May 22, 23:42
mlRe: Trying to understand -- please help... Sherm Pendley May 22, 23:59
mlRe: Trying to understand -- please help... Andy Lee May 23, 00:02