Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Buckeyes1995

macrumors member
Original poster
Mar 4, 2011
95
11
Hi all,

I'm an engineer with 15 years experience in the simulation industry. My background is FORTRAN and ADA, and a little bit of C. As a hobby, I've taken up learning Objective C (recently become a MAC convert).

The way I learn is by example. I've been scouring the Apple documentation and source code. Been a wonderful way to learn the nuances of the language.

My first question has to do with methods that are called by the OS. When I began learning objective-C (and I still have mountains to learn), one of the things that was confusing me was seeing all of these methods defined in various source files with seemingly no code making calls to these methods. I soon realized that a lot of these methods are called by the IOS OS itself (for example, touch events, init, dealloc, etc.)

Is there a resource that indicates which methods are called by IOS? Obviously I can find the answer on individual methods by researching them... I was more interested if there is some kind of tabular reference that summarizes what (and when) methods are called by the OS.

My second question has to do with Delegates. I understand the concept of delegates and delegation. What has been throwing me for a loop is when to use them. Can any of you experienced Objective-C programmers suggest guidelines you use for deciding when to use them?

Thanks for your time.
 

(marc)

macrumors 6502a
Sep 15, 2010
724
2
the woods
[...]
My first question has to do with methods that are called by the OS. When I began learning objective-C (and I still have mountains to learn), one of the things that was confusing me was seeing all of these methods defined in various source files with seemingly no code making calls to these methods. I soon realized that a lot of these methods are called by the IOS OS itself (for example, touch events, init, dealloc, etc.)

Is there a resource that indicates which methods are called by IOS? Obviously I can find the answer on individual methods by researching them... I was more interested if there is some kind of tabular reference that summarizes what (and when) methods are called by the OS.
[...]

I do not understand what you mean. Cocoa is closed-source so we non-Apple-engineers do not know it's innards. Apple's implementations obviously call methods (better: send messages), but there's no real use of knowing which methods.

[...]
My second question has to do with Delegates. I understand the concept of delegates and delegation. What has been throwing me for a loop is when to use them. Can any of you experienced Objective-C programmers suggest guidelines you use for deciding when to use them?
[...]

Think about a pancake factory. Making a pancake is really complex. So there's lots of code inside your PancakeFactory object. You, as a designer of the pancake factory do not know what people would like to do with your pancakes. So instead of putting the code that deals with the pancakes inside your PancakeFactory object (and rewriting the object whenever the use of pancakes changes), you create a PancakeFactoryDelegate protocol. Whenever your factory creates a pancake, the pancake factory's delegate is informed about it (e.g. - (void)pancakeFactory:(PancakeFactory *)factory didMakePancake:(Pancake *)pancake). The delegate can be mostly anything - a human that eats pancakes, another factory that creates cakes of pancakes, etc. *

I think your best chance of getting a feeling of when to use delegates is just using Objective-C. It's full of delegates!

* explanation is probably full of errors / inconsistencies so handle with care!
 

DaveP

macrumors 6502a
Mar 18, 2005
506
433
Your questions are at a somewhat higher level than just source code can explain. I would recommend a book or something similar to help with some of the more conceptual things. Hillegass's book is always highly recommended, but there are other good ones as well.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.