在salesforcemobilesdk-ios中使用smartStore时出错

时间:2016-07-13 11:18:47

标签: ios swift salesforce-ios-sdk

我正在创建一个与salesforcemobilesdk-ios集成的ipad应用程序。对于离线功能我正在使用smartStore框架。当我正在创造汤时,我正在传递SFSoupIndex的数组。

  

(即indecesArray)

您可以看到以下代码。

let soupIndexForAccount__c = SFSoupIndex(path: "account__c", indexType: "string", columnName: "account__c")
        let soupIndexForAddress_Line_2__c = SFSoupIndex(path: "Address_Line_2__c", indexType: "string", columnName: "Address_Line_2__c")
        let soupIndexForCity__c = SFSoupIndex(path: "City__c", indexType: "string", columnName: "City__c")
        let soupIndexForName = SFSoupIndex(path: "Name", indexType: "string", columnName: "Name")
        let soupIndexForPhone__c = SFSoupIndex(path: "Phone__c", indexType: "string", columnName: "Phone__c")
        let soupIndexForPostal_Code__c = SFSoupIndex(path: "Postal_Code__c", indexType: "string", columnName: "Postal_Code__c")
        let soupIndexForIsPersonAccount = SFSoupIndex(path: "IsPersonAccount", indexType: "string", columnName: "IsPersonAccount")
        let indecesArray:NSArray = NSArray(objects: soupIndexForAccount__c,soupIndexForAddress_Line_2__c,soupIndexForCity__c,soupIndexForName,soupIndexForPhone__c,soupIndexForPostal_Code__c,soupIndexForIsPersonAccount)
        let registeredOrNot = self.store.registerSoup("Address", withIndexSpecs: indecesArray as [AnyObject])
            print(registeredOrNot)
        exists = self.store.soupExists("Address")
        print(exists)
            let tempToCheck = self.store.allSoupNames()
        let toSee = self.store.indicesForSoup("Address")

exists的值为true。这意味着我们可以理解存在Address汤。当我尝试重审allSoupNames()时,我在nil中找到tempToCheck值。如果没有错误,toSee变量必须包含我们插入的索引值。但它显示nil

请帮我找错了

1 个答案:

答案 0 :(得分:1)

看起来你错误地提出了store声明。一切都很完美。

全局

需要声明商店变量

var store = SFSmartStore()

viewDidLoad()

store = SFSmartStore.sharedStoreWithName(kDefaultSmartStoreName) as! SFSmartStore

希望它能奏效:)