ios - 在 salesforcemobilesdk-ios 中使用 smartStore 时出错

标签 ios swift salesforce-ios-sdk

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

(i.e 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 soup。当我尝试检索 allSoupNames() 时,我在 tempToCheck 中找到了 nil 值。如果没有错误,toSee 变量必须具有我们插入的索引值。但它显示 nil

请帮我找出错误

最佳答案

看起来您错误地做了一个store 声明。一切都很完美。

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

var store = SFSmartStore()

在你的 viewDidLoad()

store = SFSmartStore.sharedStoreWithName(kDefaultSmartStoreName) as! SFSmartStore

希望它会起作用:)

关于ios - 在 salesforcemobilesdk-ios 中使用 smartStore 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38350218/

相关文章:

ios - SalesforceSDKManager 的自定义登录域

ios - 使用消耗品 IAP 时恢复 "remove ads"功能

swift - 通过关系调用核心数据属性

ios - 将 12 小时格式的 NSDate 转换为 24 小时格式

ios - 如何将 AppDelegate Swift 代码放入 Objective-C AppDelegate 文件并使其工作?

swift - 将搜索栏添加到表格 View

ios - 使用 Xcode 7.1 的 iOS 9 中的 NSURLSession/NSURLConnection HTTP 加载失败(kCFStreamErrorDomainSSL,-9813)

ios - 在 UIWebView 中渲染二进制 ms/doc 为空

android - Phonegap(非 Cordova)3.5 示例应用程序未启动设备就绪

javascript - jQuery window.one ("click") 无法在移动设备上运行