IOS SQLite user Interface Additions and deletions change case

Source: Internet
Author: User

1. Brief introduction of the caseThe SQLite operation is simply encapsulated, the operation of the data table will be transformed into the manipulation of the object, and through the UI interface completes the user table to add, delete, change, check, the execution interface for example, as seen in a
2. Projects project folder

The Usermodel class is the user object model. The corresponding Basedb class for field one by one in the database table is a simple encapsulation of sqlite, abstracting out three methods for database operations. Read more about http://blog.csdn.net/whzhaochao/article/details/38865535 Bowen UserDB inherited from Basedb. Mainly finished Usermodel object of the increase, deletion, change, check, its contents such as the following UserDB.h
  userdb.h//  sqlitedemo////  Created by Carrie on 14-8-27.//  Copyright (c) 2014 Carrie. All rights reserved.//#import "BaseDB.h" #import "UserModel.h" @interface userdb:basedb{    }//single case + (ID) shareuserdb;// Create user table-(void) Creattablewithdatabasename: (nsstring*) dbname;//Add a usermodel-(BOOL) AddUser: (usermodel*) Usermodel DbName: (nsstring*) dbname;//change a usermodel-(BOOL) UpdateUser: (usermodel*) Usermodel dbName: (nsstring*) dbname;// Query All-(nsarray*) Findalluser: (nsstring*) dbname;//Delete an Object-(BOOL) DeleteUser: (usermodel*) Usermodel dbName: (nsstring*) DbName; @end
Userdb.m
userdb.m//sqlitedemo////Created by Carrie on 14-8-27.//Copyright (c) 2014 Carrie.        All rights reserved.//#import "UserDB.h" @implementation userdbstatic UserDB * db;+ (ID) shareuserdb{if (Db==nil) {    db= [[UserDB alloc] init]; } return DB;} -(void) Creattablewithdatabasename: (nsstring*) dbname{nsstring *[email protected] "CREATE table User (UserName text prim    ary Key,password text, useremail text) ";    [Self createtable:sql databasename:dbname]; }-(BOOL) DeleteUser: (usermodel*) Usermodel dbName: (nsstring*) dbname{nsstring *[email protected] "Delete from user wh        ere userName =? ";     Nsarray *[email protected][Usermodel.username]; return [self execsql:sql parmas:params databasename:dbname];} -(BOOL) AddUser: (Usermodel *) Usermodel dbName: (NSString *) dbname{nsstring *[email protected] "insert into user (UserName , Password,useremail) VALUES (?,?,?

) "; Nsarray *[email protected][usermodel.username,usermodel.password,usermodel.useremail]; return [self execsql:sql parmas:params databasename:dbname];} -(nsarray*) Findalluser: (NSString *) dbname{nsstring *[email protected] "select Username,password,useremail from User "; Nsarray *result= [self selectsql:sql parmas:nil databasename:dbname]; Nsmutablearray *users=[nsmutablearray Array]; For (nsdictionary *dic in result) {Usermodel *user=[[usermodel alloc] init]; User.username=[dic objectforkey:@ "UserName"]; User.password=[dic objectforkey:@ "PassWord"]; User.useremail=[dic objectforkey:@ "UserEmail"]; [Users Addobject:user]; } return users; }-(BOOL) UpdateUser: (Usermodel *) Usermodel dbName: (NSString *) dbname{nsstring *[email protected] "Update user set Username=?

, password=?,useremail=? where username=? "; Nsarray *[email Protected][usermodel.username,usermodel.password,usermodel.useremail,usermodel.username]; return [self execsql:sql parmas:params databasename:dbname]; } @end


Mainviewcontroller is the display full project code download for users to display the full list of users addviewcontroller for adding and changing the user interface http://download.csdn.net/detail/whzhaochao/7829829











IOS SQLite user Interface Additions and deletions change case

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.