我正在尝试将数组对象转换为字符串,但它仍然返回对象的地址。它正在返回 - 0x5e1e370 但应该返回一些字符串值。
NSMutableArray *arrStudents = [pillboxDb getStudentRecords];
NSString *strHow = [arrStudents objectAtIndex:0];
NSLog(@"%@",strHow);
这是 getStudentRecords 的代码
+(NSMutableArray*)getStudentRecords{
NSArray *arrDocPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *strDestPath = [NSString stringWithFormat:@"%@/samplepillbox1.sqlite",[arrDocPath objectAtIndex:0]];
NSMutableArray *arrStudents = [[NSMutableArray alloc]init];
sqlite3 *db;
if(sqlite3_open([strDestPath UTF8String], &db)==SQLITE_OK)
{
NSString *query = @"select * from doctor_master";
void* v;
char* err_msg;
sqlite3_stmt *studentStmt;
if(sqlite3_prepare_v2(db, [query UTF8String], -1, &studentStmt, &err_msg)==SQLITE_OK)
{
while (sqlite3_step(studentStmt)==SQLITE_ROW) {
int sno = sqlite3_column_int(studentStmt, 0);
NSString *sname = [NSString stringWithUTF8String: sqlite3_column_text(studentStmt, 1)];
//float marks = sqlite3_column_double(studentStmt, 2);
pillbox *st = [[pillbox alloc]init];
st.Din = sno;
st.Name = sname;
[arrStudents addObject:st];
}
}
}
return arrStudents;
}