14 Mar 2011

Working my way through Init

I'm reading the book "Beginning Mac Programming" and while I'm loving the book, I think I'm stuck at a particular point. Right now I'm reading a chapter about allocating memory and initializing objects and I feel like I'm somewhat lost.

I pretty much understand the basic concept that I need to allocate the memory for all the variables than an instance of my class will use. I totally understand that I need to initialize each of those variables, too. Where I'm lost is when we start diving into just about everything else. What is "isa" (from NSObject?) and why is it important to me?

I am totally a visual learner, so I've started poking through some of the sample code that Apple provides to developers who want to learn Cocoa and Objective-C. What I would really like is, however, is a picture or a diagram or even a video about the process. Heck, even talking to a good developer while standing in front of a whiteboard would be phenomenal!

I don't really think that the concept is that odd, but I've reached the point in most programming books where I normally would start to lose interest. I have a good understanding (now) of classes, methods, instances and variables. I'm starting to understand how pointers work. I'm going to bash my way through, however, and if I don't really understand what I'm doing yet, I'll press on and revisit it at a later time.

Speaking of pointers... So, what I've got in my head is that the pointer points to a place in memory where you've stored something. That can be a variable or an instance of a class, or anything else you can stick in memory. You use the pointer, I think, because you can't pass a variable (or instance) to a different method. So, you point at the memory location where that variable is stored.

What I'm wondering about is really how you pass the memory location out of the method? So, the memory location is a value, right? Am I missing something? Is the memory location stored somewhere odd or in a different way?

Hmmm... More to wrap my head around!