jeudi 22 janvier 2015

when I Deactivate the user then i want to drop the sqlite(remove the user from sqlite)

When the User Deactivate the UsersID then i would like to to drop user from the sqlite(remove the user from 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");
}



}

Aucun commentaire:

Enregistrer un commentaire