안녕하세요, 저는 SQLite를 사용하여 내 앱의 로그인과 비밀번호를 만들려고합니다. 모든 것이 괜찮지 만 일단 로그인 버튼을 누르면 홈 페이지에 입력되지 않습니다 !!! !아이폰의 로그인과 비밀번호 확인하기
Aadhira에 의해 제안-(void)checkindatabase{
NSArray *dirPath =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir =[dirPath objectAtIndex:0];
NSString *databasePath =[[NSString alloc] initWithString:[docDir stringByAppendingPathComponent:@"login.db"]];
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK)
{
NSLog(@"open");
NSString *sql = [[NSString alloc] initWithFormat:@"select * from UserInformation where Username='%@' and Password='%@'",loginName.text,password.text]; //[sql UTF8String];
//NSLog(@"'%s'",[sql UTF8String]);
sqlite3_stmt *statement;
if (sqlite3_prepare_v2(database, [sql UTF8String], -1, &statement, NULL) == SQLITE_OK)
{ if(sqlite3_step(statement) == SQLITE_ROW)
{
//user name is correct
//if u want to print in log use below code
homepage *hvc = [[homepage alloc]initWithNibName: nil bundle: nil];
hvc.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:hvc animated: YES];
}
else {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Login Failed!!!"
message:@"Check your PId and Password" delegate:nil
cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}}
sqlite3_finalize(statement);
}
sqlite3_close(database);
}
-(IBAction)homePage: (id)sender
{
[self checkindatabase];
}
'checkindatabase' 메소드가 자격 증명의 유효성 여부에 관계없이 bool을 반환하도록하십시오. bool 값을 확인한 다음 UIAlertView가 표시되는지 아니면 사용자의 집보기가 해당 값을 사용하는지 표시하십시오. – Ilanchezhian
안녕하세요 @ Aadhira, @ Dshan 당신이 내 코드는 내가 그것을하고있다면 오류를 보여주고 있기 때문에 @ Bshay 방법을 보여 주시기 바랍니다 코드의 형태로 BOOL 메서드를 보여줄 수 있습니다 – makumar