我正在使用 PhoneGap 在 iPhone/Android 上保存联系人。总体而言,它似乎确实有效,但我已经追踪到最近的一次崩溃,即当我尝试将物理地址设置到我的contact() 对象中的contactAddress() 对象时,它会引发未捕获的异常。
我对要保存的联系人执行了 JSON.stringify:
{
"id": 41,
"rawId": null,
"displayName": "Joe Customer",
"name": {
"givenName": "Joe",
"familyName": "Customer"
},
"nickname": null,
"phoneNumbers": [
{
"name": "work",
"value": "2145556666",
"pref": true
},
{
"name": "fax",
"value": "2147778888",
"pref": true
}
],
"addresses": [
{
"streetAddress": null,
"locality": "Dallas",
"region": null,
"postalCode": null,
"country": null
}
],
"ims": null,
"organizations": [
{
"pref": true,
"type": "work",
"name": "Acme Inc.",
"department": null,
"title": "Sales Person"
}
],
"birthday": null,
"note": null,
"photos": null,
"categories": null,
"urls": [
{
"name": "website",
"value": "http://www.google.com",
"pref": true
}
]
}
当我尝试保存它时,我得到了异常:
2012-09-06 21:50:38.358 MyApp[6224:707] typeValue: (null)
2012-09-06 21:50:38.359 MyApp[6224:707] *** WebKit discarded an uncaught exception in the webView:decidePolicyForNavigationAction:request:frame:decisionListener: delegate: <NSInvalidArgumentException> -[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: type)
无论我是填写整个地址对象还是只填写一个字段,它似乎都会发生。