iPhone 编程 如何创建数据库并从中读取数据
2010-03-25 21:24:00 来源:WEB开发网NSString *aIconUrl = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 3)];
// Create a new animal object with the data from the database
Person *person = [[Person alloc] initWithName:aName title:aTitle url:aIconUrl];
// Add the animal object to the animals Array
[personArr addObject:person];
[person release];
}
}
// Release the compiled statement from memory
sqlite3_finalize(compiledStatement);
}
sqlite3_close(database);
for (Person *tmpPerson in personArr) {
NSLog(@"You can see %@ %@'s icon at %@", tmpPerson.title, tmpPerson.name, tmpPerson.iconURL);
[tmpPerson release];
}
NSLog(@"Done.");
[personArr release];
[fileManager release];
[pool release];
return (0);
}
6. 编译执行
完成修改后,运行“Build > Build and Run”, 关掉弹出的iPhone Simulator窗口,选择"Run > Console" 打开控制台,可看到如下输出信息。
赞助商链接