这是我初始化它的方式:
@property (strong, nonatomic) NSMutableDictionary<NSString *, UIImage *> *images;
这是我插入的方式:
NSString *stringDate = [self getddMMyyyyInString:firstDate]
[[self.images setObject:[UIImage imageNamed:@"rsz_fill.png"] forKey:stringDate]];
我得到的错误是
indexing expression is invalid because subscript type void is not an integral or objective c pointer type
如何将 NSString
和 UIImage
插入到 NSmutabledictionary
中?
最佳答案
@property (strong, nonatomic) NSMutableDictionary<NSString *, UIImage *> *images;
self.images = [NSMutableDictionary new];
NSString *stringDate = [NSString stringWithFormat:@"%@", [NSDate date]];
UIImage *image = [UIImage imageNamed:@"rsz_fill.png"];
[self.images setObject:image forKey:stringDate];
关于ios - 无法插入 NSMutableDictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44471509/