在 salesforcemobilesdk 中使用 smartStore 时出错-ios
error while using smartStore in salesforcemobilesdk-ios
我正在创建一个与 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
。这意味着我们可以理解存在 [=14=] 汤存在。当我试图检索 allSoupNames()
时,我在 tempToCheck
中找到了 nil
值。 toSee
如果没有错误,变量必须具有我们插入的索引值。但它显示 nil
.
请帮我找出错误
看来您的 store
声明有误。一切都很完美。
全局你需要声明一个存储变量
var store = SFSmartStore()
在你的viewDidLoad()
store = SFSmartStore.sharedStoreWithName(kDefaultSmartStoreName) as! SFSmartStore
希望它会起作用:)
我正在创建一个与 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
。这意味着我们可以理解存在 [=14=] 汤存在。当我试图检索 allSoupNames()
时,我在 tempToCheck
中找到了 nil
值。 toSee
如果没有错误,变量必须具有我们插入的索引值。但它显示 nil
.
请帮我找出错误
看来您的 store
声明有误。一切都很完美。
全局你需要声明一个存储变量
var store = SFSmartStore()
在你的viewDidLoad()
store = SFSmartStore.sharedStoreWithName(kDefaultSmartStoreName) as! SFSmartStore
希望它会起作用:)