作者:活宝贝aaaaaaaaaaaaa | 来源:互联网 | 2023-08-23 19:46
Below code generates error
下面的代码生成错误
Array element can not be nil
数组元素不能为零
when I assign the value in aryResult[0]
当我在aryResult [0]中分配值时
NSMutableArray *tempResult = [[NSMutableArray alloc] initWithCapacity:2];
switch (habitObj.NoOfTimesPer)
{
case 1://NO_OF_TIMES_PER_DAY
{
tempResult = [self getTotalNoOfDaysOrWeeks_createdDate:habitObj.strCreatedDt totalsOf:@"TOTAL_DAYS"];
}
break;
case 2://NO_OF_TIMES_PER_WEEK
{
tempResult = [self getTotalNoOfDaysOrWeeks_createdDate:habitObj.strCreatedDt totalsOf:@"TOTAL_WEEKS"];
}
break;
default:
break;
}
aryResult[0] = tempResult[0];
aryResult[3] = tempResult[1];
The code below does not generate error:
下面的代码不会产生错误:
[tempResult addObject:[NSNumber numberWithInt:0]];
[tempResult addObject:[NSNumber numberWithInt:1]];
aryResult[0] = tempResult[0];
aryResult[3] = tempResult[1];
1 个解决方案