如何在iphone的文本字段上附加数组
|
我有一个应用程序,我想在其中使用特定的ID列从数据库中获取内容,然后在按下按钮时在文本字段中显示所有内容。以下代码段显示了如何获取数组中的内容。
//this is a function which i am created which will be called in button click event
-(NSArray*)getStudents
{
NSMutableArray *studentArray=[[NSMutableArray alloc]init];
sqlite3_stmt *statement = nil;
NSString *query=@\"select * from UserInformation where UserId=?\";
const char *sql = [query cStringUsingEncoding:NSUTF8StringEncoding];
if (sqlite3_prepare_v2(dbConnection, sql, -1, &statement, NULL) == SQLITE_OK) {
while(sqlite3_step(statement) == SQLITE_ROW) {
Student *newStudent=[[Student alloc]init];
newStudent.age=sqlite3_column_int(statement, 0);
newStudent.name=[NSString stringWithUTF8String:(char *)sqlite3_column_text(statement, 1)];
[studentArray addObject:newStudent];
}
}
return studentArray;
}
我在将此数组添加到我的文本字段时遇到问题,因此当我单击按钮时,我的文本字段会从数据库中加载特定ѭ1的值。我已经在一个控制器中编写了上述函数,并且在另一个控制器中定义了文本字段。如何在文本字段中填写以上数组?
没有找到相关结果
已邀请:
1 个回复
矾醒忻