A couple of (noobish) question

Discussion in 'iOS Programming' started by Buckeyes1995, Mar 22, 2011.

  1. Buckeyes1995 macrumors member

    Joined:
    Mar 4, 2011
    #1
    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.
     
  2. (marc) macrumors 6502a

    (marc)

    Joined:
    Sep 15, 2010
    Location:
    the woods
    #2
    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.

    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!
     
  3. DaveP macrumors 6502

    DaveP

    Joined:
    Mar 18, 2005
    #3
    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.
     

Share This Page