iOS學習筆記整理4

整理筆記:

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];

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容