当我取消激活用户然后我想删除sqlite(从sqlite中删除用户)

时间:2015-01-23 05:33:37

标签: ios objective-c iphone sqlite

当用户取消激活UsersID然后我想从sqlite中删除用户(从sqlite中删除用户)

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{


    if (indexPath.row==0) {
        //Deactivate account
        NSLog(@"selected delete Account");
        BOOL success=[self DeletingAccount];
        if (success==YES) {

            [self dropTable];
            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Successfull" message:@"Your account was deleted successfully" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
            [alert show];

            //After the account is deleted navigation to login view controller
            ViewController *controller=[self.storyboard instantiateViewControllerWithIdentifier:@"vc"];
            [self.navigationController pushViewController:controller animated:YES];

        } else {

            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Unsuccessfull" message:@"Your account was not deleted try again" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
            [alert show];
        }
    }

    else {

        //Insert the code here to change user's number
        NSLog(@"selected Change Number");
    }
}


-(void)dropTable
{
    //[SSWriteReadInDb deleteAllRousInQuotesTable];
    sqlite3 *database;
    NSString *databasePath=[SSSQLite pathToDB];
    if (sqlite3_open([databasePath UTF8String], &database)==SQLITE_OK) {

        const char *sqlStatement="DROP table QuotesTable";
        char *errMsg;
        if (sqlite3_exec(database, sqlStatement, NULL, NULL, &errMsg)) {
            NSLog(@"Table dropped");
        }
        sqlite3_close(database);

    } else {
        NSLog(@"Failed to open db");
    }



}

0 个答案:

没有答案