我无法理解我的代码中发生了什么:
for (NSMutableDictionary *dict in jsonResponse) {
NSString *days = [dict objectForKey:@"dayOfTheWeek"];
NSArray *arrayDays = [days componentsSeparatedByString:@" "];
NSLog(@"la var %@ size %lu", days, sizeof(arrayDays));
for(int i = 0; i<sizeof(arrayDays); i++){
NSLog(@"el dia %@",[arrayDays objectAtIndex:i]);
}
}
我在日志中得到什么:
2012-07-02 10:06:57.191 usualBike[1342:f803] var M T W T F size 4
2012-07-02 10:06:57.191 usualBike[1342:f803] day M
2012-07-02 10:06:57.192 usualBike[1342:f803] day T
2012-07-02 10:06:57.192 usualBike[1342:f803] day W
2012-07-02 10:06:57.193 usualBike[1342:f803] day T
2012-07-02 10:06:57.193 usualBike[1342:f803] var S S size 4
2012-07-02 10:06:57.194 usualBike[1342:f803] day S
2012-07-02 10:06:57.194 usualBike[1342:f803] day S
并且崩溃,因为位置 3 不存在。
为什么第二次尺寸不变?它应该是 1。
先感谢您