title: Dividing an array into separate arrays of four elements plus the reminder
body: <p>I'm trying to divide an array into individual arrays of four elements, where the last array will contain the reminder. For example, if that main array's length property will be ten, three subarrays will be created - two consisting of four elements, and one of two elements.</p>
  
  <p>The code I have right now looks like the following:</p>
  
  <pre><code>NSMutableArray *mainMutableArray = [NSMutableArray arrayWithObjects:@"First", @"Second", @"Third", @"Fourth", @"Fifth", @"Sixth", @"Seventh", @"Eighth", nil];
  NSMutableArray *mutableArrayOfSubarrays = [NSMutableArray array];
  
  int length = mainMutableArray.count / 4;
  int location = 0;
  
  for (int i = 0; i &lt; length; i++)
  {
      [mutableArrayOfSubarrays addObject:[mainMutableArray subarrayWithRange:NSMakeRange(location, 4)]];
      location += 4;
  }
  </code></pre>
  
  <p>This of course works only when the reminder is equal to 0.</p>
  
  <p>Any help would be greatly appreciated.</p>