Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iOS中使用Sqlite数据库登录和注册_Ios_Iphone_Sqlite_Login - Fatal编程技术网

在iOS中使用Sqlite数据库登录和注册

在iOS中使用Sqlite数据库登录和注册,ios,iphone,sqlite,login,Ios,Iphone,Sqlite,Login,我想在iOS应用程序中使用Sqlite注册和登录?我已成功注册并将数据存储在表中。现在,我想通过验证我注册的用户名和密码来登录。请帮助我成功创建登录。按以下步骤操作可能对您有用 NSString *query=[NSString stringWithFormat:@"select * from peopleInfo where email=\"%@\" and password=\"%@\"",usernameTextField.text,passwordTextField.text];

我想在iOS应用程序中使用Sqlite注册和登录?我已成功注册并将数据存储在表中。现在,我想通过验证我注册的用户名和密码来登录。请帮助我成功创建登录。

按以下步骤操作可能对您有用

  NSString *query=[NSString stringWithFormat:@"select * from peopleInfo where email=\"%@\" and password=\"%@\"",usernameTextField.text,passwordTextField.text];
  NSLog(@"%@",query);
  NSLog(@"%@",self.dbManager);
  NSArray* ary = [self.dbManager loadDataFromDB:query];

  if (ary.count){
        //Login successfully
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"" message:@"login successful" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];
    }else{
        //Invalid username and password
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Error" message:@"Unsuccessful" delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
        [alert show];
    }

您能分享一些从您的终端完成的登录代码吗。NSString*query=[NSString stringWithFormat:@select*from peopleInfo,其中用户名=\%@,密码=\%@,用户名TextField.text,密码TextField.text];peopleInfo是我存储注册数据的表名。现在,在登录时,我需要验证people info表中是否存在用户名和密码。为此,我需要做什么?这是我用来执行查询的代码,其中,@property nonatomic,strong DBManager*DBManager;self.dbManager=[[dbManager alloc]initWithDatabaseFilename:@sampledb.sql];但它不起作用你知道singleton类吗?请共享DBManager类的内容NSString*query=[NSString stringWithFormat:@select*from peopleInfo,其中email=\%@,password=\%@,usernameTextField.text,passwordTextField.text];NSLog@%@,查询;[self.dbManager executeQuery];如果self.dbManager.affectedRows!=0{//登录成功}其他{//用户名和密码无效}将此输出存储在NSArray[self.dbManager executeQuery:query]中