user1418214
user1418214

Reputation: 59

how to access a newly created class in objective c

I get the feeling that this is a very stupid question, but I cannot find an answer anywhere. I've created a new class in an XCode project called "Word", with its own .h and .m files, which inherits from NSString, and has its own declared instance variable, method, etc. How do I access it within the viewcontroller.h and .m files? I though it would just show up in the little suggestion box in XCode, like the pre-made classe, but it doesn't. How do I use my new class?

Upvotes: 0

Views: 49

Answers (3)

jacerate
jacerate

Reputation: 456

in your .h, at the top type #import " then start typing Word.h. It should autocomplete if the .h and .m files are in your project correctly.

Upvotes: 1

Rob Napier
Rob Napier

Reputation: 299575

#import "Word.h"

I will note that subclassing NSString is extremely uncommon and almost never what you mean to do. You probably meant to have Word have an NSString property.

Upvotes: 3

werner
werner

Reputation: 859

You just need to add the following to your ViewController.h

#import "Word.h"

Upvotes: 0

Related Questions