Skip to content

Instantly share code, notes, and snippets.

@stevenhuey
Created January 19, 2017 16:34
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 stevenhuey/1930d7c7ff4f64ab75fe200dbe712db8 to your computer and use it in GitHub Desktop.
Save stevenhuey/1930d7c7ff4f64ab75fe200dbe712db8 to your computer and use it in GitHub Desktop.
- (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