2016-02-05 117 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 
}