Skip to content

Instantly share code, notes, and snippets.

@property (nonatomic, strong) NSArray *dataRows;
- (void)getTempData
{
NSArray *results = [[[SmartStoreInterface alloc] init] getAccount];
if(results){
_dataRows = results;
[self.tableView reloadData];
}
}
- (void)tableView:(UITableView *)itemTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[itemTableView deselectRowAtIndexPath:indexPath animated:NO];
NSDictionary *obj = [_dataRows objectAtIndex:indexPath.row];
DetailViewController *detailController =
[[DetailViewController alloc] initWithName:[obj objectForKey:@"Name"]
id:[obj objectForKey:@"Id"]];
[self.navigationController pushViewController:detailController animated:YES];
@property (nonatomic, strong) NSArray *dataRows;
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
SFRestRequest *request = [[SFRestAPI sharedInstance] requestForQuery:@"SELECT Id, Name FROM Account LIMIT 10"];
[[SFRestAPI sharedInstance] send:request delegate:self];
}
#pragma mark - SFRestAPIDelegate
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"SmartStore Sample App";
//スープ領域を作成
[[[SmartStoreInterface alloc] init] createAccountSoup];
}
- (void)pressSaveButton
{
NSDictionary *fields = @{@"Name": _nameField.text};
SFRestRequest *request = [[SFRestAPI sharedInstance] requestForUpdateWithObjectType:@"Account"
objectId:_idData
fields:fields];
[[SFRestAPI sharedInstance] send:request delegate:self];
}
#pragma mark - SFRestAPIDelegate
NSString* const kAllAccountQuery = @"SELECT {Account:Id},{Account:Name} FROM {Account}";
- (NSArray*)getAccount
{
SFQuerySpec * querySpec = [SFQuerySpec newSmartQuerySpec:kAllAccountQuery withPageSize:10];
return [_store queryWithQuerySpec:querySpec pageIndex:0];
}
- (void)upsertAccount:(NSDictionary*)account
{
if (nil != account) {
[_store upsertEntries:[NSArray arrayWithObject:account]
toSoup:kAccountSoupName];
}
}
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