• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why we don't import UIKit (for example) in implementation file?

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey,
When doing iOS development, usually you will two files: interface and implementation.
In the interface file you import what you want, like:
#import <UIKit/UIKit.h>
But in the implementation file, you don't import UIKit although you are using its classes, protocols ...
Why we don't import it?
Is it a rule in Objective-C that if you import a file in the interface file then you don't import it in the implementation file?
Thanks.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John Todd wrote:Hey,
When doing iOS development, usually you will two files: interface and implementation.
In the interface file you import what you want, like:
#import <UIKit/UIKit.h>
But in the implementation file, you don't import UIKit although you are using its classes, protocols ...
Why we don't import it?
Is it a rule in Objective-C that if you import a file in the interface file then you don't import it in the implementation file?
Thanks.


It is being imported into the implementation because the interface imports it and your implementation imports your interface.

C imports b which imports a, so c is importing a automatically.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic