This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property (nonatomic, strong) NSArray *dataRows; | |
- (void)getTempData | |
{ | |
NSArray *results = [[[SmartStoreInterface alloc] init] getAccount]; | |
if(results){ | |
_dataRows = results; | |
[self.tableView reloadData]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
self.title = @"SmartStore Sample App"; | |
//スープ領域を作成 | |
[[[SmartStoreInterface alloc] init] createAccountSoup]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)upsertAccount:(NSDictionary*)account | |
{ | |
if (nil != account) { | |
[_store upsertEntries:[NSArray arrayWithObject:account] | |
toSoup:kAccountSoupName]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |