整理筆記:
1、alt + 單機 更改距離 (上下左右)
2、class 代表與誰管關聯的意思
3、block 在arc 中 單獨釋放 block _release
4、UIPickerView? 視圖選擇器的使用
5、數據庫使用:
a、NSString *douPath =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
NSString *dbPath = [douPath stringByAppendingPathComponent:@"teachers.sqlite”];
//創建數據庫
db = [FMDatabase databaseWithPath:dbPath];
b、創建: NSString *createTableSql = [NSString stringWithFormat:@"create table if not exists teacher (id integer primary key autoincrement,name text,address text,age integer,salary integer)"];
BOOL result =[db executeUpdate:createTableSql] ;
c、添加:NSString *insertSql = [NSString stringWithFormat:@"insert into teacher(name,address,age,salary)values('%@','%@','%ld','%ld')",teacher.name,teacher.address,teacher.age,teacher.salary];
BOOL result =[db executeUpdate:insertSql];
d、查詢:NSString *selectSql = [NSString stringWithFormat:@"select * from teacher order by salary desc"];//asc 升序 ;? desc 降序
//執行查詢
FMResultSet *set =[db executeQuery:selectSql];
while ([set next]) {
Teacher *tea = [[Teacher alloc]init];
tea.name = [set stringForColumn:@"name"];
tea.address = [set stringForColumn:@"address"];
tea.age = [set intForColumn:@"age"];
tea.salary = [set intForColumn:@"salary"];
[array addObject:tea];
}
e、更新:NSString *updeSql = [NSString stringWithFormat:@"update teacher set age = '40' where age = '31'"];
BOOL result =[db executeUpdate:updeSql];
f、刪除: NSString *deleteSql = [NSString stringWithFormat:@"delete from teacher where salary = '700'"];
BOOL result =[db executeUpdate:deleteSql];