You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Andrew Forrest (JIRA)" <ji...@apache.org> on 2016/10/07 16:49:20 UTC
[jira] [Updated] (CB-11975) Search on Contacts ‘id’ field with JavaScript number type crashes in iOS
[ https://issues.apache.org/jira/browse/CB-11975?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrew Forrest updated CB-11975:
--------------------------------
Description:
I was trying to retrieve a specific contact by id in my Ionic/Cordova app, so used the following code:
{code:javascript}
return Contacts.find(
['id'],
{filter: contactId, multiple: true})
{code}
However, this crashes the iOS app at runtime with:
{noformat}
2016-10-07 17:33:12.331 MyApp[10998:1880417] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xb000000000000053
2016-10-07 17:33:12.337 MyApp[10998:1880417] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xb000000000000053'
*** First throw call stack:
(
0 CoreFoundation 0x000000010b0f334b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ab2b21e objc_exception_throw + 48
2 CoreFoundation 0x000000010b162f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010b078c15 ___forwarding___ + 1013
4 CoreFoundation 0x000000010b078798 _CF_forwarding_prep_0 + 120
5 MyApp 0x00000001097217b7 __22-[CDVContacts search:]_block_invoke_2 + 983
6 MyApp 0x0000000109723760 __42-[CDVAddressBookHelper createAddressBook:]_block_invoke_2 + 368
7 libdispatch.dylib 0x000000010e4450cd _dispatch_client_callout + 8
8 libdispatch.dylib 0x000000010e4275e5 _dispatch_barrier_sync_f_slow_invoke + 617
9 libdispatch.dylib 0x000000010e4450cd _dispatch_client_callout + 8
10 libdispatch.dylib 0x000000010e4258d6 _dispatch_main_queue_callback_4CF + 406
11 CoreFoundation 0x000000010b0b74f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
12 CoreFoundation 0x000000010b07cf8d __CFRunLoopRun + 2205
13 CoreFoundation 0x000000010b07c494 CFRunLoopRunSpecific + 420
14 GraphicsServices 0x00000001107aea6f GSEventRunModal + 161
15 UIKit 0x000000010be0df34 UIApplicationMain + 159
16 MyApp 0x000000010962e531 main + 65
17 libdyld.dylib 0x000000010e49168d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
{noformat}
Seems to only fail when {{contactId}} is a JavaScript number. Converting it to a string before searching ({{contactId+""}}) works fine.
Fault originally occurred because Contact {{id}} field in iOS is an integer… and it looks like I’m getting a JavaScript number value out of the Contacts API. Was storing this integer in SQLite (which preserves the data type), getting an integer back out, and passing it back into the {{Contacts.find()}} API.
Suggest:
* Contacts {{id}} field is supposed to return a string, so it should return a string on iOS
* {{Contacts.find()}} should coerce its arguments to correct types before calling native code.
was:
I was trying to retrieve a specific contact by id in my Ionic/Cordova app, so used the following code:
{code:javascript}
return Contacts.find(
['id'],
{filter: contactId, multiple: true})
{code}
However, this crashes the iOS app at runtime with:
{noformat}
2016-10-07 17:33:12.331 MyApp[10998:1880417] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xb000000000000053
2016-10-07 17:33:12.337 MyApp[10998:1880417] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xb000000000000053'
*** First throw call stack:
(
0 CoreFoundation 0x000000010b0f334b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ab2b21e objc_exception_throw + 48
2 CoreFoundation 0x000000010b162f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010b078c15 ___forwarding___ + 1013
4 CoreFoundation 0x000000010b078798 _CF_forwarding_prep_0 + 120
5 MyApp 0x00000001097217b7 __22-[CDVContacts search:]_block_invoke_2 + 983
6 MyApp 0x0000000109723760 __42-[CDVAddressBookHelper createAddressBook:]_block_invoke_2 + 368
7 libdispatch.dylib 0x000000010e4450cd _dispatch_client_callout + 8
8 libdispatch.dylib 0x000000010e4275e5 _dispatch_barrier_sync_f_slow_invoke + 617
9 libdispatch.dylib 0x000000010e4450cd _dispatch_client_callout + 8
10 libdispatch.dylib 0x000000010e4258d6 _dispatch_main_queue_callback_4CF + 406
11 CoreFoundation 0x000000010b0b74f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
12 CoreFoundation 0x000000010b07cf8d __CFRunLoopRun + 2205
13 CoreFoundation 0x000000010b07c494 CFRunLoopRunSpecific + 420
14 GraphicsServices 0x00000001107aea6f GSEventRunModal + 161
15 UIKit 0x000000010be0df34 UIApplicationMain + 159
16 MyApp 0x000000010962e531 main + 65
17 libdyld.dylib 0x000000010e49168d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
{noformat}
Seems to only fail when {{contactId}} is a JavaScript number. Converting it to a string before searching ({{contactId+""}}) works fine.
Fault originally occurred because Contact {{id}} field in iOS is an integer… and it looks like I’m getting a JavaScript number value out of the Contacts API. Was storing this integer in SQLite (which preserves the data type), getting an integer back out, and passing it back into the {{Contacts.find()}} API.
Suggest:
* Contacts {{id}} field is supposed to return a string, so it should return a string on iOS
* {{Contacts.find()}} should coerce its arguments to correct types before calling native code.
> Search on Contacts ‘id’ field with JavaScript number type crashes in iOS
> ------------------------------------------------------------------------
>
> Key: CB-11975
> URL: https://issues.apache.org/jira/browse/CB-11975
> Project: Apache Cordova
> Issue Type: Bug
> Reporter: Andrew Forrest
>
> I was trying to retrieve a specific contact by id in my Ionic/Cordova app, so used the following code:
> {code:javascript}
> return Contacts.find(
> ['id'],
> {filter: contactId, multiple: true})
> {code}
> However, this crashes the iOS app at runtime with:
> {noformat}
> 2016-10-07 17:33:12.331 MyApp[10998:1880417] -[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xb000000000000053
> 2016-10-07 17:33:12.337 MyApp[10998:1880417] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xb000000000000053'
> *** First throw call stack:
> (
> 0 CoreFoundation 0x000000010b0f334b __exceptionPreprocess + 171
> 1 libobjc.A.dylib 0x000000010ab2b21e objc_exception_throw + 48
> 2 CoreFoundation 0x000000010b162f34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
> 3 CoreFoundation 0x000000010b078c15 ___forwarding___ + 1013
> 4 CoreFoundation 0x000000010b078798 _CF_forwarding_prep_0 + 120
> 5 MyApp 0x00000001097217b7 __22-[CDVContacts search:]_block_invoke_2 + 983
> 6 MyApp 0x0000000109723760 __42-[CDVAddressBookHelper createAddressBook:]_block_invoke_2 + 368
> 7 libdispatch.dylib 0x000000010e4450cd _dispatch_client_callout + 8
> 8 libdispatch.dylib 0x000000010e4275e5 _dispatch_barrier_sync_f_slow_invoke + 617
> 9 libdispatch.dylib 0x000000010e4450cd _dispatch_client_callout + 8
> 10 libdispatch.dylib 0x000000010e4258d6 _dispatch_main_queue_callback_4CF + 406
> 11 CoreFoundation 0x000000010b0b74f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
> 12 CoreFoundation 0x000000010b07cf8d __CFRunLoopRun + 2205
> 13 CoreFoundation 0x000000010b07c494 CFRunLoopRunSpecific + 420
> 14 GraphicsServices 0x00000001107aea6f GSEventRunModal + 161
> 15 UIKit 0x000000010be0df34 UIApplicationMain + 159
> 16 MyApp 0x000000010962e531 main + 65
> 17 libdyld.dylib 0x000000010e49168d start + 1
> )
> libc++abi.dylib: terminating with uncaught exception of type NSException
> (lldb)
> {noformat}
> Seems to only fail when {{contactId}} is a JavaScript number. Converting it to a string before searching ({{contactId+""}}) works fine.
> Fault originally occurred because Contact {{id}} field in iOS is an integer… and it looks like I’m getting a JavaScript number value out of the Contacts API. Was storing this integer in SQLite (which preserves the data type), getting an integer back out, and passing it back into the {{Contacts.find()}} API.
> Suggest:
> * Contacts {{id}} field is supposed to return a string, so it should return a string on iOS
> * {{Contacts.find()}} should coerce its arguments to correct types before calling native code.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org