在swift中使用未声明类型'CustomObject'的错误 - ios

时间:2023-01-23 17:24:46

I have this custom object in group called madel

我在groupl中有这个自定义对象

import Foundation
public class CustomObject
{
  var Id:Int!
  init(id: Int){
    self.Id = id
  }
  var description: String {
    return "{ID=\(Id)}"
  }
}

in another file, I have this struct, my purpose is to have a static list that can be modified or accessed from anywhere in the app:

在另一个文件中,我有这个结构,我的目的是有一个静态列表,可以在应用程序的任何地方修改或访问:

struct Statics {
  static var listOfCustoms:[CustomObject] = []
}

I got this error : 在swift中使用未声明类型'CustomObject'的错误 -  ios

我收到了这个错误:

this is the whole error:

这是整个错误:

在swift中使用未声明类型'CustomObject'的错误 -  ios

Both files are added to the list of Compile Sources in the Build Phases

这两个文件都被添加到Build Phases中的Compile Sources列表中

1 个解决方案

#1


7  

Your code works for me, try to clean the project.

您的代码适合我,尝试清理项目。

Also check both files' Target membership that there's a checkmark in front of your target (your app name).

同时检查两个文件的目标成员身份,目标前面有一个复选标记(您的应用名称)。

#1


7  

Your code works for me, try to clean the project.

您的代码适合我,尝试清理项目。

Also check both files' Target membership that there's a checkmark in front of your target (your app name).

同时检查两个文件的目标成员身份,目标前面有一个复选标记(您的应用名称)。