Last active
July 3, 2017 13:42
-
-
Save simonlc/d03e100a17f98555911c51947a603e24 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
#import <React/RCTBridgeModule.h> | |
#import <MapKit/MapKit.h> | |
@interface MapKitAutocomplete : NSObject <RCTBridgeModule,MKLocalSearchCompleterDelegate> | |
@property (strong, nonatomic) MKLocalSearchCompleter *completer; | |
@end |
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
#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