[英]Importing nested struct in swift
I have a framework and a nested struct which I wish to import in my app. 我有一个框架和一个嵌套结构,希望将其导入我的应用程序。
open class SomeClass {
public struct SomeNestedStruct {
public let someProperty: Int
}
}
The goal is to import only SomeNestedStruct
. 目标是仅导入SomeNestedStruct
。 What I have tried so far is 到目前为止,我尝试过的是
import struct MyFramework.SomeClass.SomeNestedStruct
The only way around it is to import the whole class. 解决它的唯一方法是导入整个类。
This is impossible. 这是不可能的。
You can import a top level object ( struct
, enum
, class
, constant etc) from a module or a submodule. 您可以从模块或子模块导入顶级对象( struct
, enum
, class
,constant等)。 However, you cannot import an inner object. 但是,您不能导入内部对象。
根据https://docs.swift.org/swift-book/ReferenceManual/Declarations.html#grammar_import-declaration,您必须
import struct MyFramework.SomeClass.SomeNestedStruct
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.