初始化空的 NSMutableAttributedString 时崩溃

问题描述 投票:0回答:1

我在操场上有以下代码:

import Foundation

let str = NSMutableAttributedString()

当我运行它时,它崩溃并显示以下输出:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x1bb4d7d84)
  * frame #0: 0x00000001bb4d7d84 AppKit`-[NSApplication _crashOnException:] + 324
    frame #1: 0x00000001bb4d7a9c AppKit`-[NSApplication reportException:] + 580
    frame #2: 0x00000001bb581fb4 AppKit`uncaughtErrorProc + 156
    frame #3: 0x00000001b87010bc CoreFoundation`__handleUncaughtException + 800
    frame #4: 0x00000001b83c8314 libobjc.A.dylib`_objc_terminate() + 132
    frame #5: 0x00000001b84e1ea4 libc++abi.dylib`std::__terminate(void (*)()) + 20
    frame #6: 0x00000001b84e4c1c libc++abi.dylib`__cxxabiv1::failed_throw(__cxxabiv1::__cxa_exception*) + 36
    frame #7: 0x00000001b84e4bc8 libc++abi.dylib`__cxa_throw + 140
    frame #8: 0x00000001b83bff6c libobjc.A.dylib`objc_exception_throw + 420
    frame #9: 0x00000001b94e4718 Foundation`-[NSRLEArray objectAtIndex:effectiveRange:] + 188
    frame #10: 0x00000001b94f70fc Foundation`-[NSConcreteMutableAttributedString attribute:atIndex:effectiveRange:] + 52
    frame #11: 0x0000000108e76a78 PlaygroundLogger`___lldb_unnamed_symbol752 + 80
    frame #12: 0x0000000108e76c7c PlaygroundLogger`___lldb_unnamed_symbol756 + 20
    frame #13: 0x0000000108e73510 PlaygroundLogger`___lldb_unnamed_symbol614 + 60
    frame #14: 0x0000000108e73960 PlaygroundLogger`___lldb_unnamed_symbol627 + 20
    frame #15: 0x0000000108e6e98c PlaygroundLogger`___lldb_unnamed_symbol487 + 432
    frame #16: 0x0000000108e7450c PlaygroundLogger`___lldb_unnamed_symbol655 + 376
    frame #17: 0x0000000108e6d864 PlaygroundLogger`playground_log_hidden + 260
    frame #18: 0x000000010463434c $__lldb_expr26`main at MyPlayground6.playground:3:5
    frame #19: 0x00000001042863d8

这是一个新鲜的游乐场,不附属于任何项目(所以这不是扩展问题)。我很困惑并且卡住了。我最近升级到了 XCode 14。我尝试重新启动 XCode 和我的笔记本电脑,但没有成功。知道这里发生了什么吗?

swift xcode cocoa
1个回答
0
投票

如果它对任何人都有用,禁用 Malloc 堆栈日志记录将不再导致我的设备崩溃。编辑方案 -> 诊断 -> 取消选中该框。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.