Swift崩溃初始化一个属性

时间:2014-11-03 11:04:13

标签: objective-c xcode swift

我有一个项目,其中我使用objective-c和swift,不确定这是否相关但可能是。

我的课程定义如下:

@objc public class BHCloudFileManager {

    ...

}

这个类是一个单例,因此有一个属性:

public class var sharedManager: BHCloudFileManager {
    struct Singleton {
        static let instance = BHCloudFileManager()
    }
    return Singleton.instance
}

并且还声明了一个实例变量:

var cloudFilesAwaitingUpload: [BHCloudFile] = [] // crash happens on this line

值得一提的是,BHCloudFile是一个Objective-c类,而BHCloudFileManager显然是一个快速的类。首先从objective-c代码启动时调用sharedManager方法。

在我将Mac更新到Yosemite之前(可能还有Xcode升级,但我不确定)这段代码都运行良好,但现在我在属性初始化线上崩溃了。我的init()方法附加到这个数组,但这应该不是问题吗?

如果你知道可能导致这种情况的原因,我将非常感激,我有点松散的结局!


平台:

在iPad 3rd gen上的iOS 7.1上发生。在模拟器中的iOS 8.1上不会出现。

例外:

Thread 1: EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xe7ffdefe)

堆栈追踪:

0   0x2bec10c4 in dyld_fatal_error ()
1   0x2bec1f06 in dyld::halt(char const*) ()
2   0x2bec369e in dyld::fastBindLazySymbol(ImageLoader**, unsigned long) ()
3   0x3b0e40d0 in dyld_stub_binder ()
4   0x0005346c in Sparkjar.BHCloudFileManager.init (Sparkjar.BHCloudFileManager.Type)() -> Sparkjar.BHCloudFileManager at /Users/georgegreen/Code/BeeHive/BeeHive/BeeHive/models/BHCloudFileManager.swift:22
5   0x00053328 in Sparkjar.BHCloudFileManager.__allocating_init (Sparkjar.BHCloudFileManager.Type)() -> Sparkjar.BHCloudFileManager ()
6   0x000532e8 in globalinit_func1 at /Users/georgegreen/Code/BeeHive/BeeHive/BeeHive/models/BHCloudFileManager.swift:30
7   0x0185902a in __swift_once_block_invoke ()
8   0x3b0bf81e in _dispatch_client_callout ()
9   0x3b0c760e in dispatch_once_f$VARIANT$mp ()
10  0x01859016 in swift_once ()
11  0x0005d4c0 in Sparkjar.BHCloudFileManager.(sharedManager.getter : Sparkjar.BHCloudFileManager).(Singleton #1).instance.mutableAddressor : Sparkjar.BHCloudFileManager at /Users/georgegreen/Code/BeeHive/BeeHive/BeeHive/models/BHCloudFileManager.swift:30
12  0x000532b8 in Sparkjar.BHCloudFileManager.sharedManager.getter : Sparkjar.BHCloudFileManager at /Users/georgegreen/Code/BeeHive/BeeHive/BeeHive/models/BHCloudFileManager.swift:32
13  0x000533b0 in @objc Sparkjar.BHCloudFileManager.sharedManager.getter : Sparkjar.BHCloudFileManager ()
14  0x00170570 in -[BHAppDelegate setupApplication] at /Users/georgegreen/Code/BeeHive/BeeHive/BeeHive/BHAppDelegate.m:54
15  0x00170414 in -[BHAppDelegate application:didFinishLaunchingWithOptions:] at /Users/georgegreen/Code/BeeHive/BeeHive/BeeHive/BHAppDelegate.m:41
16  0x327b95a6 in -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] ()
17  0x327b8efa in -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] ()
18  0x327b358a in -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] ()
19  0x3274f708 in -[UIApplication handleEvent:withNewEvent:] ()
20  0x3274e870 in -[UIApplication sendEvent:] ()
21  0x327b2cc8 in _UIApplicationHandleEvent ()
22  0x34d95aec in _PurpleEventCallback ()
23  0x34d956d6 in PurpleEventCallback ()
24  0x2fef8ab6 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
25  0x2fef8a52 in __CFRunLoopDoSource1 ()
26  0x2fef7226 in __CFRunLoopRun ()
27  0x2fe61f4e in CFRunLoopRunSpecific ()
28  0x2fe61d32 in CFRunLoopRunInMode ()
29  0x327b1ef0 in -[UIApplication _run] ()
30  0x327ad16c in UIApplicationMain ()
31  0x001ab948 in main at /Users/georgegreen/Code/BeeHive/BeeHive/BeeHive/main.m:16

0 个答案:

没有答案