随時追記していきたい、アプリ開発初心者の自分用メモ
//現在のレコード数を確認する
-(int)RecordCount{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectry = paths[0];
NSString *databaseFilePath = [documentDirectry stringByAppendingPathComponent:@"MYDataBaseFile.db"];
FMDatabase *database = [FMDatabase databaseWithPath:databaseFilePath];
[database open];
NSString *sql = @"SELECT COUNT(*) AS COUNT FROM MyTable;";
//COUNT(*)で取り出した結果をCOUNTに入れる
FMResultSet *results = [database executeQuery:sql];
while([results next]){//必ず回す、そうしないと結果は0になる
_dataCount = [results intForColumn:@"COUNT"];
}
[database close];
return _dataCount;
}