Search code examples
ioscloudkit

break at CKContainer.defaultContainer() for ios 7 device


While debugging the app at ios 7 device, I receive the following break, despite it works for ios 8 device:

 (lldb) bt
* thread #1: tid = 0xbb78, 0x002094e2 libswiftCore.dylib`swift_getObjCClassMetadata + 10, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)

the part of the code, where the break is highlighted is following:

class CloudKitHelper {
    var container : CKContainer
    var publicDB : CKDatabase
    let privateDB : CKDatabase
    var delegate : CloudKitDelegate?
    var todos = [Todos]()

    class func sharedInstance() -> CloudKitHelper {
        return cloudKitHelper
    }

    init() {
        container = CKContainer.defaultContainer() // here the break is shown
        publicDB = container.publicCloudDatabase
        privateDB = container.privateCloudDatabase
    }

Is there any difference of declaring defaultcontainer for ios 7 and 8?


Solution

  • CloudKit requires iOS 8. Here is the high level listing of the new APIs available in iOS 8: https://developer.apple.com/ios8/

    If a capability requires a higher version of iOS than you want to target, you may be able to make the capability optional. This would take additional code to check for available functionality before running.