I've looked through a couple threads and am still lost on returning pointers.
I am currently in the process of learning Obj-C with not previous programming background.
I know some basics, but the only thing I cannot seem to grasp is in Kochan's Objective-C 2.0's book (Chapter 8 - A Point Class and Memory Allocation)
I know how to allocate, but here are the parts that confuse me:
I do not understand why the method returns pointers and such. Sorry if my question isn't clear, but can someone elaborate on why you return a pointer and not just an integer?
I am currently in the process of learning Obj-C with not previous programming background.
I know some basics, but the only thing I cannot seem to grasp is in Kochan's Objective-C 2.0's book (Chapter 8 - A Point Class and Memory Allocation)
I know how to allocate, but here are the parts that confuse me:
Code:
@interface Rectangle:NSObject
{
int width, height;
[I]XYPoint *origin;[/I]
}
[I]-(XYPoint*)origin;
-(void)setOrigin:(XYPoint*)pt;[/I]
I do not understand why the method returns pointers and such. Sorry if my question isn't clear, but can someone elaborate on why you return a pointer and not just an integer?