I have the purpose / swift side code. I'm calling a swift singleton method 3 times after crashing three times. I have reason to believe that this may be a memory problem here my code is
ViewController.m
- Called (zero) shared data {// Got three times the shared data = [SharedData sharedData]; [SharedData initSyncManager]; }
Swift shared data class
class func sharedData () - & gt; SharedData {struct singleton {static example instance = shared data ()} Return Singleton.instance} func initSyncManager () {}
Error on this line is EXC_BAD_ACCESS (code = EXC_i386_GPFLT)
'Single Singleton Return Return'
I do not know why is happening. I do not have any code in initSyncManager
and this crash occurs only when I use this code
[sharedData initSyncManager];
If I do not call the method 3 times, then there is no accident.
You can try it, because I'm using it to create singleton classes (SWIFT 2.1) and this is working well for me:
class var sharedInstance: SharedData {Static Static {Static Verteach Talk: dispatch_once_t = 0 static var Example: ShareData? = Ventricle} dispatch_postima (& amp; static.onsontocon) {Static.instance = SharedData ()} Return Static.instance! } Override init () {super.init () // initialisation}
No comments:
Post a Comment