Introduction
Hello everyone, welcome to my fourth screeencast. This is the second in my series introducing readers to Objective C. Let’s dive in.
Skill Level Beginner
Source Code
Available Here
Screencast
I film myself coding out the entire sample project for each post. I personally think going through the Screencast is the best way to learn. But feel free to look through the slides and text if that suites you better.
iCodeBlog Tutorial: Objective C 2.0 An Intro Part 2 from Collin Ruffenach on Vimeo.
Tutorial












iCodeBlogClass.m:
@implementation iCodeBlogClass
@synthesize name;
-init
{
return self;
}
@end



iCodeBlogGetsClassy.h:
#import "iCodeBlogClass.h"




iCodeBlogGetsClassy.h:
iCodeBlogClass *myNewObject = [[iCodeBlogClass alloc] init]; NSLog(@"%@", myNewObject);







iCodeBlogClass.h:
#import <Foundation/Foundation.h>
@interface iCodeBlogClass : NSObject
{
NSString *name;
}
@property (nonatomic, retain) NSString *name;
@end

iCodeBlogClass.m:
@synthesize name;


iCodeBlogGetsClassy.m:
iCodeBlogClass *myNewObject = [[iCodeBlogClass alloc] init]; [myNewObject setName:@"Collin"]; NSLog(@"%@", [myNewObject name]);



iCodeBlogClass.m:
-initWithName:(NSString *)inputName
{
self.name = inputName;
return self;
}


iCodeBlogGetsClassy.m:
iCodeBlogClass *myNewObject = [[iCodeBlogClass alloc] initWithName:@"Collin"];







iCodeBlogGetsClassy.m:
iCodeBlogClass *person1 = [[iCodeBlogClass alloc] initWithName:@"Collin"];

iCodeBlogGetsClassy.m:
iCodeBlogClass *person1 = [[iCodeBlogClass alloc] initWithName:@"Collin"]; iCodeBlogClass *person2 = [[iCodeBlogClass alloc] initWithName:@"Martin"]; iCodeBlogClass *person3 = [[iCodeBlogClass alloc] initWithName:@"vtsib"]; iCodeBlogClass *person4 = [[iCodeBlogClass alloc] initWithName:@"AppStoreMod"]; iCodeBlogClass *person5 = [[iCodeBlogClass alloc] initWithName:@"Matt"]; iCodeBlogClass *person6 = [[iCodeBlogClass alloc] initWithName:@"Brendan"]; iCodeBlogClass *person7 = [[iCodeBlogClass alloc] initWithName:@"Geoff"]; iCodeBlogClass *person8 = [[iCodeBlogClass alloc] initWithName:@"RobotGrrl"]; iCodeBlogClass *person9 = [[iCodeBlogClass alloc] initWithName:@"brandon"]; iCodeBlogClass *person10 = [[iCodeBlogClass alloc] initWithName:@"Aaron"]; iCodeBlogClass *person11 = [[iCodeBlogClass alloc] initWithName:@"Brian"]; iCodeBlogClass *person12 = [[iCodeBlogClass alloc] initWithName:@"Fernando"]; iCodeBlogClass *person13 = [[iCodeBlogClass alloc] initWithName:@"Chad"];

iCodeBlogGetsClassy.m:
NSMutableArray *myArray = [[NSMutableArray alloc] init];

iCodeBlogGetsClassy.m:
[myArray addObject:person1]; [myArray addObject:person2]; [myArray addObject:person3]; [myArray addObject:person4]; [myArray addObject:person5]; [myArray addObject:person6]; [myArray addObject:person7]; [myArray addObject:person8]; [myArray addObject:person9]; [myArray addObject:person10]; [myArray addObject:person11]; [myArray addObject:person12]; [myArray addObject:person13];



iCodeBlogGetsClassy.m:
for(iCodeBlogClass *myObject in myArray)
{
NSLog(@"%@", myObject);
}



iCodeBlogGetsClassy.m:
-(NSString *)description
{
return [NSString stringWithFormat:@"The name of the object is %@", self.name];
}



23 Comments
really cool !
I learned a lot of from it.
Hope can see more about it!!
I love this series. You make it very easy to follow, I have been looking for something like this for some time.
Keep up the good work.
I tried to download the source code but need the user name and id to download. thanks.
Linda Miller, DVM
Don’t know if the last request went through.
I am requesting a user name and password to download the source code.
Thank you
Linda Miller
Linda,
Sorry about that. No username or password required. I simply left FTP on the URL. It should be working now. Thanks for reading!
LOL I was in the video. Also great tutorial man that was awesome.
Really great tutorial! I’ve been working with xcode quite a while now, but your tutorial made some thins even clearer! Thank you!!!
Thanks for tutorial, It’s great to me, keep going man.
I’ve recently discovered this blog while I was looking for iPhone coding and Obj-C tips. All I can say is Thank You for these excellent tutorials. They are helping me a lot.
Clear explanations and very nice presentation. Just perfect.
Thanks a lot.
Just heard my name in the tutorial while i was walking around and listening to it and almost started laughing
Thanks for the credits.
Very good tutorial, believe it or not that tip about the documentation and how to properly use and read it is about the most helpful tip I have come across since I have started dealing with iPhone programming.
Great work with the videos and on providing the code. There are very few quality sites like this, and this has given me a strong foundation to objective-c/iphone programming that countless books and apple pdfs could not. Can’t wait for the next part in the series.
Great work Collin… I totally understood and ‘synthesized’ that lesson (man, that was a geeky play on words). But seriously, You have a great speaking cadence, and keep the listener engaged.
Really looking forward to future editions. Now program yourself a damn donate button and at least let a few of us buy you some beers!
best,
B.
That was an excellent tutorial! The keynote presentation was very well done and extremely polished. Keep up the good work man. I’m looking forward to your next one.
Hmmm – I’m getting a ‘page not found’ error when I try to d/l the source code.
Thanks for another great tutorial!
This is fantastic, I was hoping you could also repost the first screencast since it seems to be down? Thank you!
Thanks for the beginner’s guides! These are really making my foray into the iPhone development world alot more enjoyable (and more comprehensive).
Thank you for these screen casts! They have really helped to explain the usage of cocoa. Could you possibly post number 1 on vimeo, too?
When does part 3 come?
Very useful tutorial ! I’m really looking forward the next ones
These are better than the stanford class videos.
Please assign them a category (screencast or something) so they are easy to find on the blog.
looking forward to the next one
thanks
I had trouble in part 1 for a few minutes because I didn’t realize that xcode was case sensitive. For example, NSString is not the same as nsstring to the xcode compiler.
I have watched part 1 and I am just starting part 2. Perhaps you’ll cover that here.
I assume that at some point you cover variable allocation and DEallocation. Great tutorials so far!
Cool piece here. Learned a lot from it. You see, this should be the approach for starters. Doing a new language means being oriented with the basics like reserve words, pre-defined methods, etc… The moment you’re familiar already with the terms, and you can pitch in your stock knowledge, then it wouldn’t be a hard thing for you to move on and feel comfortable with it.
Great tutorial.. I have some general questions.
What is the difference between @class and @implementation.. When do we need one of them or both.. I’m confused..