Swift报错合集(Xcode编译器)

  • Instance member 'messageContent' cannot be used on type 'MessCellModel'; did you mean to use a value of this type instead?

    这应该是引用的东西没有加static导致的

  • Cannot convert value of type 'CGSize' to expected argument type 'CGFloat'

    就是数据类型不匹配的意思

  • Function produces expected type 'UIImageView'; did you mean to call it with '()'?

    调用函数要加括号

  • Static member 'messModel' cannot be used on instance of type 'FirstViewController'

    试图在一个实例上访问一个静态属性或方法。静态成员(static member)是与类本身关联的,而不是与类的具体实例(对象)关联。你只能通过类名来访问它们,而不能通过类的实例。如果要数数,肯定要访问实例

  • Cannot convert value of type 'Int' to expected argument type 'String'

    数据类型不匹配,我正在试图输入一个Int来匹配String

  • The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions

    编译器无法在合理的时间内完成类型检查;请尝试将表达式拆分成不同的子表达式

  • @objc' can only be used with members of classes, '@objc' protocols, and concrete extensions of classes

    这个是我不小心把函数写在另一个函数里了。。。

    1. @objc 只能用于类的成员@objc 属性适用于继承自 NSObject 的类中的方法和属性。也就是说,只有类中的实例方法、类方法和属性可以被标记为 @objc
    2. @objc 协议 :而且,@objc 还可以用于协议,表明这个协议及其遵循者可以在 Objective-C 中使用。
    3. 具体的类扩展 :对于类的扩展,只有包含具体成员的扩展也可以使用 @objc,而不能用于扩展中的泛型方法或属性等声明。
  • Thread 1: EXC_BAD_ACCESS (code=2, address=0x16d987ff0)

    野指针,检查返回的东西是否有来源。大小写是否输入正确。

  • The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions

    编译器在处理某段代码时遇到了复杂性,导致它耗费了过多的时间来进行类型检查。具体来说,它建议你将复杂的表达式拆分成更简单的部分,以便编译器能更容易理解和处理。

    这时候一般重写能解决

  • Sandbox: bash(73442) deny(1) file-write-create /Users/sakiko/Desktop/lianxi1/

    lianxi1/class3/class4/class6/clss8/Ulkit_lianxi/lianxi2026_5_08/Pods/resources-to-

    copy-lianxi2026_5_08

    这是因为系统的安全沙盒(Sandbox)阻止了脚本在指定的目录下创建或写入文件。

    解决方法:

    • 在 Xcode 左侧的工程导航栏中,点击最顶部的蓝色工程文件
    • 在右侧的主视图中,选择 Build Settings 选项卡。
    • 在搜索框(Search)中输入:ENABLE_USER_SCRIPT_SANDBOXING
    • 你会看到一个名为 "User Script Sandboxing" 的设置项。
    • 将它的值从 Yes 改为 No
  • Cannot convert value of type '()' to closure result type 'UIView'

    闭包需要一个返回值

相关推荐
hold?fish:palm15 分钟前
7 接雨水
开发语言·c++·leetcode
geats人山人海1 小时前
c# 第九章 record
开发语言·c#
早期的虫儿有鸟吃1 小时前
vue2--Vuex 模块化
开发语言·前端·javascript
浪客川1 小时前
Android的SystemUI的启动流程简析
android·开发语言
-银雾鸢尾-1 小时前
C#中的抽象类与抽象方法
开发语言·c#
萧瑟余晖2 小时前
JDK 20 新特性详解
java·开发语言
benchmark_cc2 小时前
如何用 Python 进行多周期 K 线合成与时区对齐?基于 QuantDash 与 Pandas 的量化数据清洗实战(附 GitHub 源码)
开发语言·python·github·盯盘·pandas·quantdash·量化数据
2301_794461572 小时前
Activiti/BPMN 2.0 的 4 种网关
java·服务器·开发语言
147API2 小时前
Claude Tag 进入 Slack 后,团队智能体需要哪些任务与审计字段
java·开发语言·数据库
Helen_cai2 小时前
OpenHarmony 通用状态加载、空页面、错误兜底组件封装(全局业务通用 UI 组件 API23)
开发语言·ui·华为·php·harmonyos