Skip to content

Instantly share code, notes, and snippets.

@jungchris
Created August 20, 2015 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jungchris/9512d097794862caa547 to your computer and use it in GitHub Desktop.
Save jungchris/9512d097794862caa547 to your computer and use it in GitHub Desktop.
createIndexOfSponsorsInOrganizations
// this method creates an index of the sponsors within organizations
- (void)createIndexOfSponsorsInOrganizations {
// sort first
[self createdSortedArrayOfSponsors];
// prepare new mutable array
NSMutableArray *sponsors = [[NSMutableArray alloc] init];
for (int i = 0; (i < [self.sortedArray count]); i++) {
// check each org and add those with organizationSposorLevel > 0
int sponsorLevel = [self.sortedArray[i] organizationSponsorLevel];
// add
if (sponsorLevel > 0) {
// ok to add
NSNumber *orgIndex = [self.sortedArray[i] organizationId];
[sponsors addObject:orgIndex];
}
}
self.sponsorIndex = [sponsors copy];
// NSLog(@"index array count: %lu", [self.sponsorIndex count]);
}
// optional method - create array sorted by name
- (void)createdSortedArrayOfSponsors {
// sort in ascending order
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"organizationName" ascending:YES];
NSArray *descriptors = [NSArray arrayWithObject:sortDescriptor];
self.sortedArray = [SharedConferenceObject.organizationsArray sortedArrayUsingDescriptors:descriptors];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment