Make sure the interface and implementation sections of person are in HelloWorld.m, or wherever your main routine is.
Type the following into your main routine:
1 int main (int argc, const char * argv[]) {
2 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
3
4 Person * junior;
5 junior = [Person alloc];
6 junior = [junior init];
7
8 [junior setAge:23];
9 [junior setWeight:200];
10 [junior eat];
11 [junior release];
12 [pool drain];
13 return 0;
14 }
Line 4 creates a new Person object named junior.
Line 5 grabs memory for that object.
Line 6 initializes the object.
Line 8 calls the setAge method on junior, with a parameter of 23. Junior's age is now 23.
Line 9 calls the setWeight method on junior, with a parameter of 200. Junior's weight is now 200.
Line 10 calls junior's eat method, raising junior's weight to 201.
Line 11 releases the memory allocated for junior.
Awesome tutorial and tips! thanks for sharing!
ReplyDeleteThis looks good, everything is in order. Where do you see yourself heading in life?
ReplyDeleteTotally lost me on this one.
ReplyDeleteI would love some more basic stuff like, the most used codes ect :P
ReplyDeleteLooks good! Nice one to start with.
ReplyDeletegreat post. following you
ReplyDeletebut what does junior look like?
ReplyDeletebesides being 23 and 200 pounds
@Whereas
ReplyDeleteGood question.
Pff i have to learn
ReplyDelete