Skip to content

Instantly share code, notes, and snippets.

@daichi1021
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daichi1021/9679832 to your computer and use it in GitHub Desktop.
Save daichi1021/9679832 to your computer and use it in GitHub Desktop.
NSString* const kAccountSoupName = @"Account";
NSString* const kAllAccountQuery = @"SELECT {Account:Id},{Account:Name} FROM {Account}";
@interface SmartStoreInterface ()
@property (nonatomic, strong) SFSmartStore *store;
@end
@implementation SmartStoreInterface : NSObject
- (id)init
{
self = [super init];
if (nil != self) {
//kDefaultSmartStoreNameはデフォルトで@"defaultStore"が設定されています
_store = [SFSmartStore sharedStoreWithName:kDefaultSmartStoreName];
}
return self;
}
- (void)createAccountSoup
{
if (![_store soupExists:kAccountSoupName]) {
//ここで各項目に対応するキーの値を設定します(これは固定です)
NSArray *keys = @[@"path", @"type"];
//「項目名, 型」でスープ領域で仕様する項目を定義します
NSArray *nameValues = @[@"Name", kSoupIndexTypeString];
NSDictionary *nameDictionary = [NSDictionary dictionaryWithObjects:nameValues forKeys:keys];
NSArray *idValues = @[@"Id", kSoupIndexTypeString];
NSDictionary *idDictionary = [NSDictionary dictionaryWithObjects:idValues forKeys:keys];
//ここで各項目のIndexを作成します
NSArray *practiceIndexSpecs = @[idDictionary, nameDictionary];
[_store registerSoup:kAccountSoupName withIndexSpecs:practiceIndexSpecs];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment