I’ve some question regarding Objective C in Xcode 4.2.
How do I correctly call a class member method. For example if I had a class called MyClass with a method draw. At the moment i’m trying this.
MyClass *myclass;
myclass = [MyClass alloc];
[myclass draw];
I can’t be creating my class instance correctly because a breakpoint in the draw method is never reached.
I’m also curious as to where the main function calls occur in an Xcode 4.2 project. If I wanted to make a game with a function called setup where would I call setup?
Any help appreciated as i’m trying to familiarize with Xcode and Objective C.
You should send the
initmessage to initialize the object:A rarely used option is the
newmethod, which is a combination ofallocandinit:The latter is shorter, but unconventional as it can be confusing when using Objective-C++. Also see the
NSObjectclass reference.For your setup method, you can set up things in the
applicationDidFinishLaunching:method of your application delegate (or in themainfunction in a daemon or command line application). Xcode’s templates have themainfunction in a file calledmain.m.