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'

    闭包需要一个返回值

相关推荐
东坡肘子12 小时前
SPI 加入 Apple,Swift 迈向自举 -- 肘子的 Swift 周报 #142
人工智能·swiftui·swift
神奇的程序员6 天前
开发了一个进阶版Apple健康
swiftui·apple·apple watch
东坡肘子7 天前
Swift 还让你 Excited 吗?-- 肘子的 Swift 周报 #141
人工智能·swiftui·swift
sweet丶10 天前
Swift 元编程-Macro
swift
LDR00613 天前
Type-C 快充全面升级!LDR6601 赋能个人护理便携电机,重塑剃须刀 / 理发器新体验
c语言·开发语言
雪碧聊技术13 天前
Tree.js是什么?一文讲透
开发语言·javascript·ecmascript
码云数智-园园13 天前
C++20 Modules 模块详解
java·开发语言·spring
swordbob13 天前
NIO的channel中什么是 fd(File Descriptor,文件描述符)
java·开发语言·nio
源分享13 天前
Java线程同步的多种实现方法(非常详细)
java·开发语言·jvm
Luminous.13 天前
C语言--day30
c语言·开发语言