名前、連絡先、電子メールIDを格納するために使用されるデータベースコンセプトを実装した小さなiPhoneアプリケーションを作成しています。私はいつでも私はユーザーが任意の連絡先を保存すると、それはテーブルビューに表示されます。 - (IBAction)retriveall:(id)送信者アクション私はデータベースからすべてのデータを取得し、配列に格納しています。今、私はすべてのデータをtableviewに表示したいと思います。データベースのデータを表示するテーブルビューを実装します
どうすればいいですか?私を助けてください。
-(IBAction)retriveall:(id)sender
{
[self retrive2];
for (int i =0; i< [namearray count]; i++)
{
NSLog(@"Name is:%@",[namearray objectAtIndex:i]);
NSLog(@"Password is:%@",[passarray objectAtIndex:i]);
}
}
-(IBAction)retrive:(id)sender
{
[self retrive1];
two.text = databasecolorvalue;
UIAlertView *favAlert=[[UIAlertView alloc] initWithTitle:@"" message:@"Retrived" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[favAlert show];
[favAlert release];
}
-(void)retrive1
{
databaseName = @"med.sqlite";
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
databasePath = [documentsDir stringByAppendingPathComponent:databaseName];
@try {
if(sqlite3_open([databasePath UTF8String], &database) == SQLITE_OK) {
const char *sqlStatement="select pswd from Login where username = ? ";
sqlite3_stmt *compiledStatement;
if(sqlite3_prepare_v2(database, sqlStatement, -1, &compiledStatement, NULL) == SQLITE_OK) {
// Loop through the results and add them to the feeds array
// Create a new animal object with the data from the database
sqlite3_bind_text(compiledStatement, 1, [one.text UTF8String], -1, SQLITE_TRANSIENT);
while(sqlite3_step(compiledStatement) == SQLITE_ROW) {
databasecolorvalue =[NSString stringWithUTF8String:(char*)sqlite3_column_text(compiledStatement,0)];
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
}
@catch (NSException * ex) {
@throw ex;
}
@finally {
}
}