iOS中的Google商家信息自动填充

时间:2015-05-24 00:48:41

标签: ios objective-c autocomplete google-places-api

我正在尝试使用此项目https://github.com/AdamBCo/GooglePlacesAutocomplete 但是当我下载它并把我的密钥"密钥用于浏览器应用程序"它给了我这个错误(当我开始输入搜索字段时)。

2015-05-24 01:37:36.154 GooglePlacesAutocomplete[6780:185340] Length: 1
2015-05-24 01:37:36.806 GooglePlacesAutocomplete[6780:185340] Search: 0
2015-05-24 01:37:36.806 GooglePlacesAutocomplete[6780:185340] AutoComplete URL: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=I&types=establishment|geocode&location=0,0&radius=500&language=en&key=???   (removed my key here)
2015-05-24 01:37:37.100 GooglePlacesAutocomplete[6780:185340] -[__NSCFConstantString objectForKeyedSubscript:]: unrecognized selector sent to instance 0x102f7d410
2015-05-24 01:37:37.112 GooglePlacesAutocomplete[6780:185340] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFConstantString objectForKeyedSubscript:]: unrecognized selector sent to instance 0x102f7d410'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000104715a75 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000104f97bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010471cd1d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
    3   CoreFoundation                      0x00000001046749dc ___forwarding___ + 988
    4   CoreFoundation                      0x0000000104674578 _CF_forwarding_prep_0 + 120
    5   GooglePlacesAutocomplete            0x0000000102f78824 -[SearchViewController tableView:cellForRowAtIndexPath:] + 308
    6   UIKit                               0x0000000103384e03 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508
    7   UIKit                               0x0000000103364901 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2846
    8   UIKit                               0x000000010337a78c -[UITableView layoutSubviews] + 213
    9   UIKit                               0x00000001033071c3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
    10  QuartzCore                          0x0000000103118c58 -[CALayer layoutSublayers] + 150
    11  QuartzCore                          0x000000010310d87e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    12  QuartzCore                          0x000000010310d6ee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    13  QuartzCore                          0x000000010307b36e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
    14  QuartzCore                          0x000000010307c482 _ZN2CA11Transaction6commitEv + 390
    15  QuartzCore                          0x000000010307caed _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
    16  CoreFoundation                      0x000000010464a507 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    17  CoreFoundation                      0x000000010464a460 __CFRunLoopDoObservers + 368
    18  CoreFoundation                      0x0000000104640293 __CFRunLoopRun + 1123
    19  CoreFoundation                      0x000000010463fbc6 CFRunLoopRunSpecific + 470
    20  GraphicsServices                    0x0000000106dc0a58 GSEventRunModal + 161
    21  UIKit                               0x000000010328d580 UIApplicationMain + 1282
    22  GooglePlacesAutocomplete            0x0000000102f75153 main + 115
    23  libdyld.dylib                       0x00000001068ef145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

我正在使用Xcode 6和iPhone 6模拟器。 任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:3)

对于我的上一个项目,我写了一个库来实现你正在尝试的东西。它是在iOS应用程序中添加自动填充Google地方搜索功能的插入式控件。

只需3个步骤即可集成它。这里是: https://github.com/mrugrajsinh/MVAutocompletePlaceSearchTextField