Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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