2011-10-11 77 views
2

我想一個NSMutableArray添加到NSDictionary但在日誌中顯示NSDictionary,當我得到這個問題:ADDOBJECT NSMutableArray的一個NSDictionary中

)' of class '__NSCFArray'. Note that dictionaries and arrays in 
property lists must also contain only property valúes. 

這是我用來創建NSMutableDictionary

NSMutableDictionary *training = [[NSMutableDictionary alloc] init]; 
[training setObject:[NSNumber numberWithInt:eltiempo] forKey:@"tiempototal"]; 
[training setObject:[NSNumber numberWithFloat:totalkm] forKey:@"distanciatotal"]; 
[training setObject:[NSNumber numberWithInt:(int)(velocidadmedia/60)] forKey:@"velocidadmedia"]; 
[training setObject:[NSString stringWithFormat:@"%2d:%02d min/km"] forKey:@"fecha"]; 
[training setObject:posiciones forKey:@"posiciones"]; 
代碼

其中posiciones是我想要添加的數組。我將這個字典保存在一個數組中以便將其保存在用戶默認值中。但因爲我有這個問題,NSDictionary沒有創建。

感謝您的幫助。

佩德羅

+2

也許這不是問題,但我看到關鍵字「fecha」的無效字符串格式。 – Mat

+0

'posiciones'是什麼類型? – DarkDust

+2

您沒有粘貼整個日誌消息。問題似乎是數組或字典包含不屬於祝福屬性列表類型組(NSString,NSArray,NSDictionary,NSDate,NSData,NSNumber)的對象。 –

回答

-5

佩德羅皮涅拉布恩迪亞,

試試這個代碼,

NSMutableDictionary *woRows = [[NSMutableDictionary alloc] init]; 
NSMutableArray *workOrders = [[NSMutableArray alloc] init]; 

[woRows setValue:[workOrders objectAtIndex:0] forKey:@"somekey"]; 
[woRows setValue:[workOrders objectAtIndex:1] forKey:@"somekey"]; 
[woRows setValue:[workOrders objectAtIndex:2] forKey:@"somekey"]; 
+1

-1:與海報已經在做什麼不同,沒有字。我爲一個人看不到任何東西(除了你的代碼覆蓋了三次相同的密鑰,並會崩潰,但它是示例代碼)。 – DarkDust

0

你把它添加到陣列就好了^^要寫入的plist(根據錯誤)和posiciones包含非plist類型,不能用於plist

相關問題