Created
August 20, 2015 12:31
-
-
Save jungchris/9512d097794862caa547 to your computer and use it in GitHub Desktop.
createIndexOfSponsorsInOrganizations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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