Skip to content

Instantly share code, notes, and snippets.

@simonlc
Last active July 3, 2017 13:42
Show Gist options
  • Save simonlc/d03e100a17f98555911c51947a603e24 to your computer and use it in GitHub Desktop.
Save simonlc/d03e100a17f98555911c51947a603e24 to your computer and use it in GitHub Desktop.
#import <React/RCTBridgeModule.h>
#import <MapKit/MapKit.h>
@interface MapKitAutocomplete : NSObject <RCTBridgeModule,MKLocalSearchCompleterDelegate>
@property (strong, nonatomic) MKLocalSearchCompleter *completer;
@end
#import "MapKitAutocomplete.h"
@implementation MapKitAutocomplete
RCT_EXPORT_MODULE();
- (id)init {
self = [super init];
self.completer = [[MKLocalSearchCompleter alloc] init];
self.completer.delegate = self;
self.completer.queryFragment = @"LA"; // <--------------- Works
return self;
}
RCT_EXPORT_METHOD(query:(NSString *)query)
{
self.completer.queryFragment = query; // <--------------- Doesn't work
NSLog(@"%@", query);
}
// XXX: This never gets called when `self.completer.queryFragment` is updated
- (void) completerDidUpdateResults:(MKLocalSearchCompleter *)completer {
for (MKLocalSearchCompletion *completion in completer.results) {
NSLog(@"------ %@", completion.description);
}
}
- (void) completer:(MKLocalSearchCompleter *)completer didFailWithError:(NSError *)error {
NSLog(@"Completer failed with error: %@", error.description);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment