gpt4 book ai didi

ios - 实例成员 'availableModes' 不能用于类型 'UIScreen'

转载 作者:行者123 更新时间:2023-11-30 13:50:24 25 4
gpt4 key购买 nike

我在尝试访问 documented 时遇到构建错误UIScreen 的属性。

重现

  • Xcode 版本 7.2 (7C68)
  • iOS 9.2
  • swift

尝试编译 -

import UIKit

class ViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

print(UIScreen.availableModes)
}
}

构建日志

Build target ass of project ass with configuration Debug

Create product structure

/bin/mkdir -p /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Products/Debug-iphonesimulator/ass.app

CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
cd /Users/maximveksler/Developer/ass
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -incremental -module-name ass -Onone -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk -target x86_64-apple-ios9.2 -g -module-cache-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ModuleCache -Xfrontend -serialize-debugging-options -enable-testing -I /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Products/Debug-iphonesimulator -F /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Products/Debug-iphonesimulator -c -j8 /Users/maximveksler/Developer/ass/ass/ViewController.swift /Users/maximveksler/Developer/ass/ass/AppDelegate.swift -output-file-map /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/ass-OutputFileMap.json -parseable-output -serialize-diagnostics -emit-dependencies -emit-module -emit-module-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/ass.swiftmodule -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-generated-files.hmap -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-own-target-headers.hmap -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-all-target-headers.hmap -Xcc -iquote -Xcc /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-project-headers.hmap -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/DerivedSources/x86_64 -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/DerivedSources -Xcc -DDEBUG=1 -emit-objc-header -emit-objc-header-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/ass-Swift.h -Xcc -working-directory/Users/maximveksler/Developer/ass

CompileSwift normal x86_64 /Users/maximveksler/Developer/ass/ass/ViewController.swift
cd /Users/maximveksler/Developer/ass
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -primary-file /Users/maximveksler/Developer/ass/ass/ViewController.swift /Users/maximveksler/Developer/ass/ass/AppDelegate.swift -target x86_64-apple-ios9.2 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk -I /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Products/Debug-iphonesimulator -F /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-generated-files.hmap -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-own-target-headers.hmap -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-all-target-headers.hmap -Xcc -iquote -Xcc /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-project-headers.hmap -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/DerivedSources/x86_64 -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/maximveksler/Developer/ass -emit-module-doc-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/ViewController~partial.swiftdoc -Onone -module-name ass -emit-module-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/ViewController~partial.swiftmodule -serialize-diagnostics-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/ViewController.dia -emit-dependencies-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/ViewController.d -emit-reference-dependencies-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/ViewController.swiftdeps -o /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/ViewController.o

/Users/maximveksler/Developer/ass/ass/ViewController.swift:16:15: error: instance member 'availableModes' cannot be used on type 'UIScreen'
print(UIScreen.availableModes)
^~~~~~~~ ~~~~~~~~~~~~~~

CompileSwift normal x86_64 /Users/maximveksler/Developer/ass/ass/AppDelegate.swift
cd /Users/maximveksler/Developer/ass
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/maximveksler/Developer/ass/ass/ViewController.swift -primary-file /Users/maximveksler/Developer/ass/ass/AppDelegate.swift -target x86_64-apple-ios9.2 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk -I /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Products/Debug-iphonesimulator -F /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Products/Debug-iphonesimulator -enable-testing -g -module-cache-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ModuleCache -serialize-debugging-options -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-generated-files.hmap -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-own-target-headers.hmap -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-all-target-headers.hmap -Xcc -iquote -Xcc /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/ass-project-headers.hmap -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/DerivedSources/x86_64 -Xcc -I/Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/maximveksler/Developer/ass -emit-module-doc-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/AppDelegate~partial.swiftdoc -Onone -module-name ass -emit-module-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/AppDelegate~partial.swiftmodule -serialize-diagnostics-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/AppDelegate.dia -emit-dependencies-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/AppDelegate.d -emit-reference-dependencies-path /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/AppDelegate.swiftdeps -o /Users/maximveksler/Library/Developer/Xcode/DerivedData/ass-endgssgsbtcuwefqpkdefxgnlbqo/Build/Intermediates/ass.build/Debug-iphonesimulator/ass.build/Objects-normal/x86_64/AppDelegate.o

最佳答案

availableModes 是一个属性,应该在 UIScreen 实例上使用。

print(UIScreen.mainScreen().availableModes)

我试图使用 UIScreen 类上的属性,但它不起作用。从 API POV 来看,这也完全有意义,因为抽象屏幕的投注屏幕模式没有多大意义。

关于ios - 实例成员 'availableModes' 不能用于类型 'UIScreen',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34364414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com