0

我有一个 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];

            }
        }

我使用上面的代码从数据库中获取数据提前致谢

4

2 回答 2

2

检查您班级的父Currency班级。父类应该NSObject和不UIView相似。


请查看Objective-C 命名约定。只有类应该以大写字母开头。

于 2012-10-19T18:01:43.100 回答
0

从外观上看,您添加了一些空视图或其他内容。既然您要添加“Obj”,您不应该知道它是什么类型的对象吗?你到底想做什么?

于 2012-10-19T17:08:44.710 回答