NSDocument


#1

Hi.
I am relatively new to cocoa, could someone explains me why when we use NSDocument we have to create 2 .h and 2.m files?
What is the use of making this?
Thanks


#2

[quote=“gadl07”]Hi.
I am relatively new to cocoa, could someone explains me why when we use NSDocument we have to create 2 .h and 2.m files?
What is the use of making this?
Thanks[/quote]

hm… I only had to create Person.m/h in chapter 8, as MyDocument.m/h is already there when you create a document-based Cocoa application


#3

In general, you create two files for each class; the .h file contains the declarations, and the .m file is the implementation. The reason for that (well, one of the reasons) is that you can include the .h file in other files; that allows you reference classes and its methods from other classes.

For example, in MyDocument.m, you have #import “Person.h”; that allows you to call methods of the Person class in MyDocument.m.

Cheers,
Frank+++