我有一个NSMutableDictionary称为“myScheduleFullDictionary”成立这样的:的NSMutableDictionary + NSMutableArray的崩溃
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
不知道为什么它指出“名称”为“name”是我声明和正在使用的“Session”类的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
'name'在哪里被使用? – yeesterbunny 2013-02-12 00:44:02
查看更新的问题 – sirab333 2013-02-12 00:50:56
您确定这是导致错误的行吗?你有没有添加异常断点?日志应该工作没有意义,但不是下一行。 – rdelmar 2013-02-12 00:50:58