AsIm Gunduz
AsIm Gunduz

Reputation: 25

Adding a class in objective-c

I'm new to Xcode and I'm trying to understand how things work, studying from books, reading tutorials etc.. and I got a minor problem

when I create a new project using " Command Line Tool" if I manually create the class interface, implementation and then write the codes to the main it works perfectly

however, as you know when a project is created through CommandLineTool it only provides main.m I click on the file -> add new file and select objective-c class, name the class and then it provides me classname.m and classname.h and when I write the codes they don't work, the main somehow doesn't see the other files I mean main and class.h and class.m are not connected I think because when I start writing

classname *newclassname= [[classname alloc] init];

the classname doesn't show up so any suggestions what am I doing wrong? I am sorry for my bad english and thanks in advance

Upvotes: 0

Views: 62

Answers (2)

Leo Chapiro
Leo Chapiro

Reputation: 13984

Seems like you need this one:

#import "classname.h"

Upvotes: 0

Sverrisson
Sverrisson

Reputation: 18157

Objective-C is case sensitive so take care when writing classname or Classname, check that for all the code. Also the convention is to use Uppercase for class names and lowercase for variables and instances. Variables are usually written with camelCase so newclassname will be newClassname:

Classname *newClassname= [[Classname alloc] init];

Upvotes: 1

Related Questions