gpt4 book ai didi

ios - SKLabelNode 崩溃

转载 作者:行者123 更新时间:2023-12-02 01:48:41 24 4
gpt4 key购买 nike

新类总是在设备 iOS 9 上崩溃,并且 NewLabel 上的访问错误(文本:“”)。

为什么?

import SpriteKit

class NewLabel : SKLabelNode {

override var text: String {
didSet {

}
}

}


* thread #1: tid = 0x8c839, 0x000000018577ce38 CoreFoundation`CFStringCreateCopy + 32, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x000000018577ce38 CoreFoundation`CFStringCreateCopy + 32
frame #1: 0x0000000100ee49d8 libswiftCore.dylib`function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Dead> of Swift.String.init (Swift.String.Type)(_cocoaString : Swift.AnyObject) -> Swift.String + 108
frame #2: 0x0000000100ec85b0 libswiftCore.dylib`Swift.String.init (Swift.String.Type)(_cocoaString : Swift.AnyObject) -> Swift.String + 24
frame #3: 0x0000000100112eac Project`Project.NewLabel.text.setter : Swift.String(newValue=Swift.String at 0x000000016fd259d8, self=0x0000000154fd7d30) + 124 at NewLabel.swift:0
frame #4: 0x0000000100112e24 Project`@objc Project.NewLabel.text.setter : Swift.String + 72 at NewLabel.swift:0
frame #5: 0x000000018ac78528 SpriteKit`+[SKLabelNode labelNodeWithText:] + 96
frame #6: 0x000000010014b5c0 Project`@!objc ObjectiveC.SKLabelNode.__allocating_init (ObjectiveC.SKLabelNode.Type)(text : Swift.String) -> ObjectiveC.SKLabelNode + 84 at AppDelegate.swift:0
* frame #7: 0x0000000100148fb4 Project`Project.AppDelegate.application (application=0x0000000154fbe420, launchOptions=None, self=0x0000000154d351e0)(ObjectiveC.UIApplication, didFinishLaunchingWithOptions : Swift.Optional<Swift.Dictionary<ObjectiveC.NSObject, Swift.AnyObject>>) -> Swift.Bool + 96 at AppDelegate.swift:21
frame #8: 0x000000010014a5f4 Project`@objc Project.AppDelegate.application (Project.AppDelegate)(ObjectiveC.UIApplication, didFinishLaunchingWithOptions : Swift.Optional<Swift.Dictionary<ObjectiveC.NSObject, Swift.AnyObject>>) -> Swift.Bool + 204 at AppDelegate.swift:0
frame #9: 0x000000018ae5f1a0 UIKit`-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 400
frame #10: 0x000000018b087e7c UIKit`-[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 2904
frame #11: 0x000000018b08c1c0 UIKit`-[UIApplication _runWithMainScene:transitionContext:completion:] + 1660
frame #12: 0x000000018b089300 UIKit`-[UIApplication workspaceDidEndTransaction:] + 168
frame #13: 0x000000018f5db7ec FrontBoardServices`-[FBSSerialQueue _performNext] + 184
frame #14: 0x000000018f5dbb6c FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 56
frame #15: 0x000000018584c5a4 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #16: 0x000000018584c038 CoreFoundation`__CFRunLoopDoSources0 + 540
frame #17: 0x0000000185849d38 CoreFoundation`__CFRunLoopRun + 724
frame #18: 0x0000000185778dc0 CoreFoundation`CFRunLoopRunSpecific + 384
frame #19: 0x000000018ae580c8 UIKit`-[UIApplication _run] + 460
frame #20: 0x000000018ae52f60 UIKit`UIApplicationMain + 204
frame #21: 0x000000010014b2e0 Project`main + 164 at AppDelegate.swift:14
frame #22: 0x000000019acb28b8 libdyld.dylib`start + 4

我发现 Sprite 套件属性已更改(左 Xcode 6.4 - 右 Xcode 7)。 enter image description here

最佳答案

SKLabelNode 的 text 属性在 iOS9 中是可选的。

覆盖 var text: String? 应该可以。

关于ios - SKLabelNode 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32695259/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com