我有一個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