I have objective / swift code side by side. I am calling a swift singleton method 3 times. After three times it crashes. I have reason to believe this might be a memory problem. Here is my code
ViewController.m
-(void)sharedData
{
// called three times
sharedData = [SharedData sharedData];
[sharedData initSyncManager];
}
Swift sharedData class
class func sharedData() -> SharedData
{
struct Singleton
{
static let instance = SharedData()
}
return Singleton.instance
}
func initSyncManager()
{
}
The error is EXC_BAD_ACCESS (code=EXC_i386_GPFLT) on this line
'return Singleton.instance'
I have no idea why this is occurring. I have no code in initSyncManager
at all and this crash only happens when I use this piece of code
[sharedData initSyncManager];
If I don't call the method 3 times, the crash doesn't occur.