Xcode6-Beta4 でプレイグラウンドで遊んでみました。次のように入力します。
import UIKit
let color = NSColor.blueColor()
エラーは次のとおりです。
Use of unresolved identifier 'NSColor'
誰かが理由を説明できますか?
Xcode6-Beta4 でプレイグラウンドで遊んでみました。次のように入力します。
import UIKit
let color = NSColor.blueColor()
エラーは次のとおりです。
Use of unresolved identifier 'NSColor'
誰かが理由を説明できますか?
iOS 向けに開発していてimport UIKit
(コードが示すように) を使用している場合、適切なカラー インターフェイスはUIColor
. そのような:
iOS と OS X の両方で動作することを意図したコードの場合は、次を使用できます。
#if os(macOS) || targetEnvironment(macCatalyst)
import AppKit
typealias ColorType = NSColor
#elseif os(iOS)
import UIKit
typealias ColorType = UIColor
#endif
let color = ColorType.blackColor()
NSColor はAppKitの一部です( https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSColor_Class/Reference/Reference.html_ )
UIColor は UIKit の一部です( https://developer.apple.com/library/ios/documentation/uikit/reference/UIColor_Class/Reference/Reference.html )
UIKitをインポートするか、次のように置き換えますNSColor
。UIColor