-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGithubRepositories.m
More file actions
36 lines (28 loc) · 1.03 KB
/
Copy pathGithubRepositories.m
File metadata and controls
36 lines (28 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//
// GithubRepositories.m
// TableViewModel
//
// Created by Luke Redpath on 10/08/2010.
// Copyright 2010 LJR Software Limited. All rights reserved.
//
#import "GithubRepositories.h"
@implementation GithubRepositories
+ (NSArray *)exampleRepositories
{
return [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"repositories" ofType:@"plist"]];
}
+ (NSArray *)repositoryNamesInGroupsOf:(NSInteger)numberOfItemsInSection
{
NSMutableArray *objectsInSections = [NSMutableArray arrayWithObject:[NSMutableArray array]];
__block NSMutableArray *currentSection = [objectsInSections objectAtIndex:0];
[[[self exampleRepositories] valueForKeyPath:@"@unionOfObjects.name"] enumerateObjectsUsingBlock:^(id object, NSUInteger idx, BOOL *stop) {
if (idx > 0 && (idx % numberOfItemsInSection) == 0) {
currentSection = [NSMutableArray arrayWithObject:object];
[objectsInSections addObject:currentSection];
} else {
[currentSection addObject:object];
}
}];
return objectsInSections;
}
@end