出于某种原因,我无法将数组添加到 nsmutabledictionary。我在这里将它声明为我的 .h 文件中的属性:
@interface TCMExhibitFeedStore : NSObject
@property (nonatomic, strong) NSMutableDictionary *allLevels;
@property (nonatomic, strong) NSMutableDictionary *storedLevels;
+ (TCMExhibitFeedStore *)sharedStore;
- (void)fetchExhibtFeedWithCompletion:(void (^)(NSMutableDictionary *obj, NSError *err))block;
- (TCMLevel *)createLevel:(TCMLevelRemote *)l;
- (TCMExhibit *)createExhibit:(TCMExhibitRemote *)e;
- (BOOL)saveChanges;
@end
然后,我试图在 .m 文件中的函数中添加一个空数组,如下所示
[_storedLevels setObject:[[NSMutableArray alloc] init] forKey:@"levels"];
但是,当我单步执行该应用程序时,它永远不会被添加。在调试器中查看显示为
_storedLevels NSMutableDictionary * 0x00000000
NSMutableDictionaries 对我来说并不新鲜。我只是有点疯狂地试图找到我的错误,因为这对我来说看起来很正常。