creating my own reusable classes

Discussion in 'iOS Programming' started by pier, Jun 24, 2011.

  1. pier macrumors 6502

    pier

    Joined:
    Feb 7, 2009
    #1
    I come from an AS3 background where there is a classpath where you can put your own classes. I'm just starting out with Xcode 4, Objective C, etc.

    For example I have my "Utils" class, "Numbers" class, etc. I use them in my AS3 projects for frequent stuff. What I do is create static methods (as in class methods) so I don't have to create an instance to do Numbers.convertRadToDeg(34)

    AFAIK in ObjC it would be something like that [Numbers convertRadToDeg:34]

    ¿So how would I approach this in Objective C?
    ¿Is there a folder where I can put my classes?
    ¿Do I have to create my own framework?
    ¿Is it a good idea to use class methods to do that in Objective C?

    TIA
     
  2. jnoxx macrumors 65816

    jnoxx

    Joined:
    Dec 29, 2010
    Location:
    Aartselaar // Antwerp // Belgium
    #2
    U create a classmethod called Numbers, you import it in every other class, and do [Numbers convertRadToDeg:34]; if it has this method ofcourse, and if it has parameters.
    A folder? just create a group in your xcode proj. Right click, new group, tadaa, just put em in there. If you really want them in a seperate group in your tree structure (in your Finder). Then you add a new group, and give it a new path via (more options) on it .. well, it was like this in xcode 3.2.5, havent used it in 4.0.x

    You can create your own framework, but not alot of people do that (I tend to believe..)
    And sure, why not use class methods? it cleans up your code mostly by a bunch. And makes it easier to navigate through your code.
     

Share This Page