I am trying to add an NSMutableArray
to an NSDictionary
but I get this issue when show NSDictionary
in log:
)' of class '__NSCFArray'. Note that dictionaries and arrays in
property lists must also contain only property valúes.
This is the code I use to create the 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"];
Where posiciones is the array I want to add. I save this dictionary in an array in order to save it in User Defaults. But as I have this problem the NSDictionary
is no created.
Thanks for you help.
Pedro
您将其添加到数组就好了^^您要写入一个plist(根据错误),并且posiciones包含不能在plist中使用的非plist类型
Pedro Piñera Buendia,
Try this code,
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"];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.