IOS SQLite user Interface Additions and deletions change case

Source: Internet
Author: User

1. Case briefA simple encapsulation of the sqlite operation, the operation of the data table operation into the object, and through the UI interface to complete the user table to add, delete, change, check, run the interface as shown in a
2. Project Engineering Catalogue

Usermodel class for the user object model, and the database table field one by one corresponds to the Basedb class for the simple encapsulation of SQLite, abstract the database operation of three methods, the specific content see http://blog.csdn.net/whzhaochao/article/ details/38865535 Bowen UserDB inherited in Basedb, mainly to complete the Usermodel object of the increase, deletion, change, check, and its contents are as follows 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;//Modify 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 primary Key,password text, useremail text) ";    [Self createtable:sql databasename:dbname]; }-(BOOL) DeleteUser: (usermodel*) Usermodel dbName: (nsstring*) dbname{nsstring *[email protected] "Delete from us        er where 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 (US    Ername,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 a display full item code download for users to display all user lists Addviewcontroller for adding and modifying 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.