我有一个名为“myScheduleFullDictionary”的 NSMutableDictionary,设置如下:
KEY VALUE
"Day 1" An NSMutableArray of NSMutableDictionaries
"Day 2" An NSMutableArray of NSMutableDictionaries
"Day 3" An NSMutableArray of NSMutableDictionaries
等等
我正在尝试解析它 - 基本上抓住其中一个 MutableArrays 作为其中一个键的值。这是我的代码:
// First I make a mutableCopy of the entire Dictionary:
NSMutableDictionary *copyOfMyScheduleDictionary = [myScheduleFullDictionary mutableCopy];
// Next I grab & sort all the KEYS from it:
NSArray *dayKeysArray = [[copyOfMyScheduleDictionary allKeys] sortedArrayUsingSelector:@selector(compare:)];
// I set up an NSMutableArray to hold the MutableArray I want to grab:
NSMutableArray *sessionsInThatDayArray = [[NSMutableArray alloc] init];
// Then I iterate through the KEYs and compare each to the one I'm searching for:
for (int i = 0; i < [dayKeysArray count]; i++) {
NSString *currentDayKey = [dayKeysArray objectAtIndex:i];
if ([currentDayKey isEqualToString: targetDayString]) {
NSLog(@"FOUND MATCH!!!");
// I log out the NSMutableArray I found - which works perfectly:
NSLog(@"found array is: %@", [copyOfMyScheduleDictionary objectForKey:currentDayKey]);
// But when I try to actually grab it, everything crashes:
sessionsInThatDayArray = [copyOfMyScheduleDictionary objectForKey:currentDayKey];
break;
}
}
我得到的错误是:
-[__NSDictionaryM name]: unrecognized selector sent to instance 0x1c5fb2d0
不知道为什么将“名称”指出为“无法识别的选择器”。“名称”是我声明并正在使用的“会话”类的 NSString 属性 - 这可能以某种方式相关吗?
有什么见解吗?
编辑:
这是我的“SessionObject”类定义:
@interface SessionObject : NSObject
@property (nonatomic, strong) NSString *name;
@property (nonatomic, strong) NSString *speaker;
@property (nonatomic, strong) NSString *location;
@property (nonatomic, strong) NSDate *startTime, *endTime;
@property (nonatomic, strong) NSString *notes;
@property (nonatomic, strong) NSString *dayOfConference;
@end