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'

    闭包需要一个返回值

相关推荐
弹简特11 小时前
【零基础学Python】08-Python面向对象之封装、多态和函数进阶
开发语言·python
人道领域11 小时前
一篇文章解决Codex的安装,实操一遍过
java·开发语言·codex
thisiszdy11 小时前
<C++> 智能指针
开发语言·c++
fox_lht11 小时前
第十四章 一个输入和输出项目:构建一个命令行程序
开发语言·后端·rust
郑州光合科技余经理11 小时前
海外版外卖系统:如何快速搭建国际化外卖平台
java·开发语言·前端·人工智能·小程序·系统架构·php
Cheng小攸12 小时前
协议分析与分析工具(一)
开发语言·php
fox_lht12 小时前
14.2.读文件
开发语言·后端·rust
codeejun12 小时前
每日一Go-74、Go 云原生可观测性实战之OpenTelemetry 全链路采集:Trace + Metrics + Logs
开发语言·云原生·golang
神仙别闹12 小时前
基于 Python 实现 ANN 与 KNN 的图像分类
开发语言·python·分类
yugi98783812 小时前
基于Qt的实用二维码生成解决方案
开发语言·qt