Reputation: 10068
I often create subclass of UIViewController
in Xcode, but sometimes XCode auto imports Cocoa, and sometimes it auto imports UIKit. I was just wondering what's the reason behind this inconsistency?
Upvotes: 0
Views: 159
Reputation: 1114
The difference is because you are adding a new "Cocoa Class" vs a "Cocoa Touch Class". When you add a new file, select iOS > source. Not OS X > Source (scroll down to see it).
Xcode doesn't always default to the right file.
Upvotes: 2
Reputation: 101
In Xcode when you create a new file and choose your file template:
If you choose iOS / Cocoa Touch Class and sub-class UIViewController, it'll import UIKit
If you choose OSX / Cocoa Class and sub-class UIViewController, it'll import Cocoa
I've noticed sometimes Xcode won't always open the file template window on the same view as your last New File operation. Double check to see if this is what's causing the inconsistency.
Upvotes: 3