我有一個NSMutableArray的,我喜歡[appDelegate.array addObject:Obj];
分配對象,就當我打電話NSLog(@"appdelegate.array %@ ", [appdelegate.array description]) ;
我越來越喜歡這個在CONSOLNSMutableArray中包含一些未知數據
(
"<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];
}
}
我上面的代碼用來從數據庫中獲取數據 由於提前
我的猜測:貨幣是'UIView'的一個子類而不是'NSObject' –
當你NSLog一個NSArray的時候,它所做的就是輸出開始和結束的'()'字符,並在中間調用'description '爲陣列中的每個對象。所以你的數組中有一些產生'description'輸出的對象(大概是因爲它們是UIView的子類)。你總是可以重寫'description'來在你定義的類中輸出(幾乎)任何你想要的內容。 –
@Matthias Bauch suprub感謝兄弟它解決了我的問題實際上我在5小時內遇到了很多問題 –