NSMutableArray包含一些未知数据

时间:2012-10-19 16:29:46

标签: iphone ios5 xcode4

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

            }
        }

我使用上面的代码从数据库中获取数据 在此先感谢

2 个答案:

答案 0 :(得分:2)

检查Currency班级的家长班级。父类应为NSObject而不是UIView或类似。


请看一下Objective-C naming conventions。只有课程应以大写字母开头。

答案 1 :(得分:0)

通过它的外观你添加了一些空的视图或其他东西。既然你要添加“Obj”,你应该不知道它是什么类型的对象?你甚至想做什么?