This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
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: 17309
11
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
Boost this thread!