I'm new to Objective-C and trying to get my head around pointers. This isn't my first port of call; I'm hoping somebody will be able to discern the source of my confusion and explain this concept in plain English.
In the following code (from a Treehouse lesson) an instance, ball, of an object class, Sphere, is created.
#import <Cocoa/Cocoa.h>
#import "Sphere.h"
int main()
{
Sphere *ball = [[Sphere alloc] init];
[ball setRadius:25];
NSLog(@"ball radius %f", [ball radius]);
return 0;
}
I understand that in Objective-C, all instances of an object class are pointers.
I understand that 'the ball pointer points to the memory that is allocated for the ball object', as someone else noted for me elsewhere.
But what's happening in terms of actual memory allocation?
Are the 'instance' and the 'pointer' the same thing, created at the same time?