SKLabelNode崩溃

时间:2015-09-21 12:29:16

标签: ios crash sprite-kit ios9 sklabelnode

New class始终在设备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 kit propeties已经改变了(左Xcode 6.4 - 右Xcode 7)。 enter image description here

1 个答案:

答案 0 :(得分:0)

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

override var text: String?应该有用。