2016-02-05 85 views
-1

这里是日志:For循环尽管记录计数为阵不循环绕环

2016-02-05 08:17:39.037 ASAP[70510:7996026] sortTasksIntoDaySeperatedArrays | SORTED_TASKS:(
     { 
     "TASK_DURRATION" = 1; 
     "TASK_NAME" = Now; 
     "TASK_START_TIME" = 1454678259; 
    }, 
     { 
     "DAY_OF_WEEK" = Sunday; 
     "TASK_DURRATION" = 600; 
     "TASK_NAME" = "Sunday Breakfast 9AM"; 
     "TASK_START_TIME" = 1454853634; 
    } 
) 
2016-02-05 08:17:39.065 ASAP[70510:7996026] DAYS_COUNT:7 
2016-02-05 08:17:39.065 ASAP[70510:7996026] FINAL_END_GAME_ARRAY:(
) 

功能

-(void)sortTasksIntoDaySeperatedArrays{ 

    NSMutableArray *FinalSortedDaysArray=[[NSMutableArray alloc]init]; 
    NSMutableArray *nextSevenDaysArray=[self nextSevenDays]; 
    NSLog(@"NEXT_SEVEN:%@",nextSevenDaysArray); 
    NSMutableArray *sortedTasks=[self getAndSortAllTasks]; 
    NSLog(@"sortTasksIntoDaySeperatedArrays | SORTED_TASKS:%@",sortedTasks); 
    NSLog(@"DAYS_COUNT:%lu",(unsigned long)nextSevenDaysArray.count); 

    int q; 
    for(q = 0;q ==7;q = q + 1){ 
     NSLog(@"LOOP"); 


    } 


    NSLog(@"FINAL_END_GAME_ARRAY:%@",FinalSortedDaysArray); 

} 
+0

你能在你的问题展开您所看到的问题。 –

+0

看到我添加的日志....它记录了该数组有7个计数,但是当它进入循环时,它从不记录LOOP一词。 – ChuckKelly

+0

这是疯狂......即使这样也不会注销任何东西: - (void)theLoop int q;对于(q = 0; q == 7; q = q + 1),为 NSLog(@“LOOOP”); } } – ChuckKelly

回答

4
for(q = 0;q ==7;q = q + 1) 
{ 
    // do stuff 
} 

这将通过在测试循环条件是成立的 - 也就是说,当q = 7时,它将永远不会发生,因为您已将它设置为0

如果你想通过直到 Q = 7,你做这样的

for(q = 0;q < 7; q++) 
{ 
    // do stuff 
}