我想在appDelegate类中打开我的SQLite数据库,并在我需要数据库的所有其他类中引用该数据库.我尝试过使用:static sqlite3*database = nil;
但是当我尝试使用appDelegate.database在我的其他类中引用它时,我得到一个编译错误"错误:请求成员'数据库',而不是结构或联合." 你如何引用这些类型的属性?
您应该通过以下通用公式访问存储在app Delegate中的任何变量:
YourAppDelegateName *delegate = (YourAppDelegateName *)[[UIApplication sharedApplication]delegate];
//access specific variables in delegate as follows:
sqlite3 *temp = delegate.database;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1827 次 |
| 最近记录: |