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) CBLLiveQuery *liveQuery; | |
//ViewDidLoadに以下を追加します。 | |
AppDelegate *ap = ApplicationDelegate; | |
self.liveQuery = [[ap.database queryAllDocuments] asLiveQuery]; | |
[self.liveQuery addObserver:self forKeyPath:@"rows" options:0 context:NULL]; |
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)deleteDocument:(CBLModel *)model{ | |
NSError *err; | |
BOOL ok = [model deleteDocument:&err]; | |
// 削除実行 | |
if (ok) { | |
NSLog(@"Delete Complete!"); | |
} | |
else{ | |
[self showErrorAlert:@"Couldn't delete the item"]; |
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)updateDocument:(NSIndexPath *)indexPath{ | |
// check情報を取得 | |
ShoppingItem *item = dataArray[indexPath.row]; | |
// Updateを準備する | |
NSError *err; | |
item.check = !item.check; | |
BOOL ok = [item save:&err]; |
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)loadAllDocuments{ | |
// appDelegate呼び出し | |
AppDelegate *ap = ApplicationDelegate; | |
// ArrayをClear | |
[dataArray removeAllObjects]; | |
// すべてのクエリを読み込む | |
CBLQuery *allQuary = [ap.database queryAllDocuments]; | |
// appDelegate呼び出し |
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)createDocument{ | |
// Appdelegateを呼ぶ | |
AppDelegate *ap = ApplicationDelegate; | |
// カウントの読み込み | |
NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults]; | |
// カウントが0だったら(ユーザデフォルトが存在しなければ)1にする | |
int num = [userDefault integerForKey:NUMBER_KEY]; |
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
ShoppingItem.h | |
@interface ShoppingItem : CBLModel | |
@property BOOL check; | |
@property (nonatomic, copy) NSString *type; | |
@property (nonatomic, copy) NSString *text; | |
@property (nonatomic, copy) NSDictionary *dictionary; | |
@property (nonatomic, copy) NSArray *array; | |
@property (nonatomic, strong) NSDate *created_at; |
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)deleteDocument:(NSString *)documentId{ | |
// AppDelegateを呼ぶ | |
NSError *err; | |
AppDelegate *ap = ApplicationDelegate; | |
CBLDocument* doc = [ap.database documentWithID:documentId]; | |
// 削除実行 | |
if (![doc deleteDocument:&err]) { | |
[self showErrorAlert:@"Couldn't delete the item"]; | |
} | |
else{ |
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)updateDocument:(NSIndexPath *)indexPath{ | |
// check情報を取得 | |
NSMutableDictionary *dataDic = [NSMutableDictionary dictionaryWithDictionary:dataArray[indexPath.row]]; | |
// 現在のチェックを受け取る | |
BOOL wasChecked = [[dataDic valueForKey:@"check"] boolValue]; | |
// 結果を反転させてセットする | |
[dataDic setObject: [NSNumber numberWithBool: !wasChecked] forKey:@"check"]; | |
// Updateを準備する | |
NSError *err; |
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
#pragma strict | |
private var center : Vector3; | |
private var target : GameObject; | |
private var moving : boolean; | |
private var fixJoint : FixedJoint; | |
function Start () { | |
center = Vector3(Screen.width/2, Screen.height/2, 0); | |
moving = false; |
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
#pragma strict | |
private var center : Vector3; | |
private var target : GameObject; | |
private var moving : boolean; | |
function Start () { | |
center = Vector3(Screen.width/2, Screen.height/2, 0); | |
moving = false; |
NewerOlder