I know that there are many questions on stackoverflow about the differences between @class forward declarations and #imports - and I do understand that it is mostly compiler optimization and reducing circular import problems.
My question is more about coding style in the following circumstances, say for instance I have a model structure like below.
// Classroom.h
@class Teacher;
@interface ClassRoom : NSObject
@property (nonatomic, strong) Teacher *teacher;
- (NSArray *)students;
@end
// Teacher.h
@interface Teacher : NSObject
@property (nonatomic, strong) NSString *firstName;
@property (nonatomic, strong) NSString *lastName;
@end
Now, when I am using this in another class I would need to import both Teacher.h and ClassRoom.h if I wanted to access the firstName property via
teacherObject.firstName
Whereas if I used #import Teacher.h instead of @class Teacher; I would only have to import #Teacher.
So my main question is if this is a reasonable occasion to use an import instead of a forward declaration? The actual model structure I am using in my project is much more complex than this and I often have to import 5-10 different model classes at the beginning of my implementation files (in the controllers). While this does not hurt anything it does become frustrating and make the source code longer. I would love to hear opinions on this from Objective-C veterans.