Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 7, 2011, 09:13 PM   #1
teguh123
macrumors member
 
Join Date: Mar 2011
In Init, does self refer to the class or the instance?

Also is there any case where we call alloc and not init after that?

What confuses me is things like

self= [super init]

Basically, if self is a pointer to the class, we're tell self to point to the address described by [super init]

The problem with that is self should already point to whatever address returned by alloc right?

So why change it?
__________________
How to Learn Math
teguh123 is offline   0 Reply With Quote
Old Apr 8, 2011, 01:09 PM   #2
Catfish_Man
macrumors 68030
 
Catfish_Man's Avatar
 
Join Date: Sep 2001
Location: Portland, OR
Send a message via AIM to Catfish_Man
In any instance method (-), self refers to the instance. In any class method (+), self refers to the class. Always call an init method after calling +alloc. The reason to set it is that some classes play tricks in -init and don't return the same object that +alloc did.
Catfish_Man is offline   0 Reply With Quote
Old Apr 8, 2011, 01:28 PM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
Cocoa Fundamentals Guide

In particular, read the sub-section on "Basic Subclass Design". Ideally, you should read the entire guide.
chown33 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How Do I get a reference to the openDocument method in first responder tmeehan Mac Programming 2 Feb 16, 2012 07:12 AM
Does Apple just not listen to the consumer? Or not care...or hellodon iPhone 27 Jul 7, 2008 09:18 PM
64 Bit, does it just have to be the OS or the machine too? erandall38 OS X 3 Aug 9, 2007 12:52 AM
Apple DVI to Video adapter - does it use the digital or the analog signal? snowlord Mac Peripherals 5 Jan 25, 2007 02:15 PM


All times are GMT -5. The time now is 05:40 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC