Created
January 19, 2017 16:34
-
-
Save stevenhuey/1930d7c7ff4f64ab75fe200dbe712db8 to your computer and use it in GitHub Desktop.
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
- (void)indexAirportData | |
{ | |
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ | |
for (ALAirport* airport in self.airports) | |
{ | |
// Create the attribute set | |
CSSearchableItemAttributeSet* attributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString*)kUTTypeItem]; | |
attributeSet.displayName = airport.airportName; | |
attributeSet.latitude = @(airport.coordinate.latitude); | |
attributeSet.longitude = @(airport.coordinate.longitude); | |
attributeSet.thumbnailData = UIImagePNGRepresentation([UIImage imageNamed:@"AppIcon"]); | |
// Create the searchable item | |
CSSearchableItem* item = [[CSSearchableItem alloc] initWithUniqueIdentifier:airport.airportIdentifier | |
domainIdentifier:@"airports" | |
attributeSet:attributeSet]; | |
[[CSSearchableIndex defaultSearchableIndex] indexSearchableItems:@[item] | |
completionHandler:^(NSError * _Nullable error) { | |
NSLog(@"Indexed: %@", airport.airportName); | |
}]; | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment