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'

    闭包需要一个返回值

相关推荐
海盗12341 小时前
C#中使用MiniExcel 快速入门:读写 .xlsx 文件
开发语言·windows·c#
XMYX-01 小时前
29 - Go time 时间模块详解:时间处理、定时控制与底层设计
开发语言·golang
小小de风呀1 小时前
de风——【从零开始学C++】(七):string类详解
开发语言·c++·算法
丘比特惩罚陆1 小时前
制作类似aimlab的测试手速反应力的小游戏
开发语言·javascript·visual studio
江屿风1 小时前
【c++笔记】类和对象流食般投喂(中)
开发语言·c++·笔记
csbysj20201 小时前
C 语言输入与输出(I/O)详解
开发语言
Huangjin007_1 小时前
【C++ STL篇(八)】set容器——零基础入门与核心用法精讲
开发语言·c++·学习
c#上位机1 小时前
C#项目中打包文件的三种方式
开发语言·c#
hehelm1 小时前
C++ 特殊类设计
开发语言·c++