我是否需要在 iOS 中导入 uikit 和基础框架?

问题描述

当我创建 .swift 文件时,Foundation 框架是认实现的。 但是当我必须使用 UIKit 框架时,我也会导入 UIKit 框架。

我认为 UIKit 包含基础框架。 (有点担心因为导入了两次基础框架。)

哪个代码更好?

#1 只需导入 UIKit 框架。 导入 UIKit

#2 导入两个框架。 进口基金会 导入 UIKit

有什么不同吗?

解决方法

是的 UIKit 包含 Foundation,UIKit 顾名思义添加了 UI 元素。 Foundation 主要有基本数据类型(字符串、整数、日期等)和非 GUI 函数,如打印

[https://developer.apple.com/documentation/swift/swift_standard_library/][基金会] [https://developer.apple.com/documentation/uikit][UIKit]