我有一个 NSMutableArray 并且我正在为它分配对象,就像[appDelegate.array addObject:Obj];
我打电话时NSLog(@"appdelegate.array %@ ", [appdelegate.array description]) ;
我在 consol 中一样
(
"<Item: 0x6c8b650; frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; alpha = 0; opaque = NO; layer = (null)>",
"<Item: 0x6b825c0; frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; alpha = 0; opaque = NO; layer = (null)>",
"<Item: 0x6b82ad0; frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; alpha = 0; opaque = NO; layer = (null)>"
)
任何人都可以建议我更正格式以添加对象以及为什么数组包含frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; alpha = 0; opaque = NO; layer = (null)
?
+ (void) getInitialCurrencyToDisplay:(NSString *)dbPath{
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) {
const char *sql = "select c_name,C_Id from Currency";
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) {
while(sqlite3_step(selectstmt) == SQLITE_ROW) {
NSInteger primaryKey = sqlite3_column_int(selectstmt, 1);
Currency *Obj = [[Currency alloc]initWithPrimaryKey:primaryKey];
Obj.C_Name = [NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 0)];
Obj.address=[NSString stringWithUTF8String:(char *)sqlite3_column_text(selectstmt, 1)];
NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDir = [documentPaths objectAtIndex:0];
NSLog(@"%@", documentsDir);
NSString *pngFilePath = [NSString stringWithFormat:@"%@/%@.png",documentsDir, Obj.C_Name];
Obj.C_Image = [[UIImage alloc] initWithContentsOfFile:pngFilePath];
Obj.isDirty = NO;
[appDelegate.array addObject:Obj];
}
}
我使用上面的代码从数据库中获取数据提前致谢