How to Create a Class in Objective-C

Custom classes are an essential building block in Objective-C. Ultimately, all iOS apps are made up of objects that are instantiated from classes. Here is an example of how you can code classes in Objective-C.

Objective-C Custom Class Example Header File (MyClass.h)

#import <Foundation/Foundation.h>
@interface MyClass : NSObject

@property(strong) NSString *name;



Objective-C Custom Class Example Implementation File (MyClass.m)

#import "MyClass.h"
@implementation MyClass @synthesize name;

     NSLog(@"name = %@",;


Pretty simple huh?

5 thoughts on “How to Create a Class in Objective-C

  1. Just came across this tutorial, I’m a newbie in iPhone app and like to try your tutorial, it will be great if you could please fix the link to the source code used in this tutorial, thank you!

    1. Hi Summer,

      Got it – the source code actually should be in the blog post. But, because we’ve recently moved this blog over from another platform some of the content fell through the cracks. I’ll be putting this post back on my list to revise right now.

        1. I don’t think so – I’m actually coming out with a really big Objective-C series that I think will be way more useful and I can’t find a copy of that code on my desktop :(

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>