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'

    闭包需要一个返回值

相关推荐
速易达网络6 分钟前
Three.js 动画入门教学:从场景搭建到流畅动效
开发语言·javascript·ecmascript
福大大架构师每日一题10 分钟前
excelize v2.11.1发布:Go 1.26.0起步,16项安全修复与嵌入对象能力全面升级
开发语言·安全·golang
Sarvartha12 分钟前
集合概述 & Collection 接口
开发语言
lhbweilai38 分钟前
QT项目(串口助手)
开发语言·qt
eggwyw44 分钟前
C++相交链表和反转链表详解
开发语言·c++
Wang's Blog1 小时前
Java 项目实战:交友项目 - 保存访客记录
java·开发语言·交友
Raas1001 小时前
AI网关如何接入?MAI Gateway部署实操教程
java·开发语言·人工智能·gateway·ai网关·mai gateway·企业级产品
小小龙学IT1 小时前
Go 语言 pprof 性能剖析与调优深度解析:把“卡在哪“变成一张可执行的数据图
开发语言·后端·golang
starzy19902 小时前
Scala Set深度解析:为什么大数据开发离不开它?
大数据·开发语言·scala
熊猫钓鱼>_>2 小时前
三方库 NDK 原生模块跨平台适配与调试【鸿蒙心迹】
开发语言·华为·ai编程·harmonyos·鸿蒙·openharmony·鸿蒙心迹