swift - 为什么 CIContext.init() 不应该返回 nil?
问题描述
我真的很困惑,因为我遇到了构造函数在根据 API 定义不应该CIContext
返回的情况。nil
我有这个代码:
if (context == nil) {
print("creating default context")
context = CIContext()
print("default context is nil: ", context == nil)
}
if (context == nil) {
print("creating context 1 with options")
context = CIContext(options: [.allowLowPower: true])
print("context is nil: ", context == nil)
}
if (context == nil) {
print("creating context 2 with options")
context = CIContext(options: [.useSoftwareRenderer: true])
print("context is nil: ", context == nil)
}
它给了我这个输出:
creating default context
default context is nil: true
creating context 1 with options
context is nil: true
creating context 2 with options
context is nil: false
即前两个块初始化context
为零。当 API 说它不应该为 nil 时,这怎么可能呢?
顺便说一句:这仅发生在 CI 机器上,这些机器是 7 岁的 Mac Pro,可能没有连接显示器。
解决方案
推荐阅读
- android - 制作Flutter插件时如何在原生android端实现Notification?
- polygon - 从哪里获得 Matic 的 Chainlink VRF 代币?
- scala - 在函数 Spark-Scala 中迭代计算
- azure - Azure CDN 规则引擎从标头设置 cookie
- php - 实现 TranslationInterface 时未找到映射文件
- java - firestore 等待 get 完成并检索列表
- r - 在 R Shiny 中使用 renderUI 时如何在多个滑块上使用 setSliderColor 更改滑块颜色
- python - 在python中检查ini格式
- python - 如何忽略数据集中的特定时期(Python)
- r - 将多参数函数应用于R中列表中的所有数据框