1

我正在创建一个与 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. 如果没有错误,变量必须具有我们插入的索引的值。但它正在显示。tempToChecktoSeenil

请帮我找出错误

4

1 回答 1

1

看起来你做了store错误的声明。一切都很完美。

全局你需要声明一个存储变量

var store = SFSmartStore()

在你的viewDidLoad()

store = SFSmartStore.sharedStoreWithName(kDefaultSmartStoreName) as! SFSmartStore

希望它会工作:)

于 2016-07-14T08:25:30.223 回答