- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在我的应用程序中,Crashlytics 用于收集用户的崩溃报告。这是一位用户的崩溃报告。这可能取决于用户的联系人信息。我无法重现崩溃,因为我不知道他/她的联系人中有什么。有人知道这种情况吗?
com.apple.root.default-priority Crashed
0 CoreFoundation CFStringCreateCopy + 13
1 AppSupport CPSqliteDatabaseCreateWithPath + 36
2 AppSupport CPSqliteDatabaseCreateWithPath + 36
3 AppSupport CPRecordStoreGetDatabase + 16
4 AppSupport _getReaderConnection + 10
5 AppSupport CPRecordStoreProcessQueryWithBindBlock + 22
6 AppSupport CPRecordStoreCopyAllInstancesOfClassWhereWithBindBlock + 98
7 AddressBook ABCCopyArrayOfAllPeopleInSourceWithSortOrdering + 244
8 SeeYouKee PhoneNumberInputViewController.m line 538-[PhoneNumberInputViewController dofetchContacts:]
9 AddressBook __37-[ABTCC accessRequestWithCompletion:]_block_invoke_0 + 26
10 TCC __TCCAccessRequest_block_invoke_038 + 316
11 ... libxpc.dylib _xpc_connection_call_reply + 26
12 libdispatch.dylib _dispatch_root_queue_drain + 278
13 libdispatch.dylib _dispatch_worker_thread2 + 92
14 libsystem_c.dylib _pthread_wqthread + 360
8 SeeYouKee PhoneNumberInputViewController.m 的代码第 538 行-[PhoneNumberInputViewController dofetchContacts:]
是:
NSArray *contactsInAddressBook = CFBridgingRelease(ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, nil, kABPersonSortByLastName));
编辑 1
-(void)dofetchContacts:(ABAddressBookRef)addressBook{
NSMutableArray *contactMutArr = [NSMutableArray array];
NSMutableString *mStrOfContacts = [NSMutableString string];
NSArray *contactsInAddressBook = CFBridgingRelease(ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, nil, kABPersonSortByLastName));
if (ABPersonGetCompositeNameFormat() == kABPersonCompositeNameFormatLastNameFirst) {
for (id aPerson in contactsInAddressBook) {
ABRecordRef person = (__bridge ABRecordRef)(aPerson);
ABMultiValueRef phoneMultiValue = ABRecordCopyValue(person, kABPersonPhoneProperty);
ABMultiValueRef emailMultiValue = ABRecordCopyValue(person, kABPersonEmailProperty);
int countPhone = 0;
int countEmail = 0;
NSMutableArray *phoneStrArr;
NSMutableArray *emailStrArr;
if (phoneMultiValue != NULL) {
countPhone = ABMultiValueGetCount(phoneMultiValue);
}
if (emailMultiValue != NULL) {
countEmail = ABMultiValueGetCount(emailMultiValue);
}
if (countEmail>0) {
emailStrArr = [NSMutableArray array];
for (int i = 0; i < countEmail; i++) {
CFStringRef anEmailCF = ABMultiValueCopyValueAtIndex(emailMultiValue, i);
NSString *anEmail = (__bridge NSString *)anEmailCF;
[emailStrArr addObject:anEmail];
if (anEmailCF != NULL)CFRelease(anEmailCF);
}
}
if (countPhone > 0) {
phoneStrArr = [NSMutableArray array];
for (int i = 0; i < countPhone; i++) {
CFStringRef anPhoneCF = ABMultiValueCopyValueAtIndex(phoneMultiValue, i);
NSString *anPhone = (__bridge NSString *)anPhoneCF;
NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet];
NSString *anPhonePureNumber = [[anPhone componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
[phoneStrArr addObject:anPhonePureNumber];
if (anPhoneCF != NULL)CFRelease(anPhoneCF);
}
}
// if (arrRefOfEmails != NULL)CFRelease(arrRefOfEmails);
CFStringRef lastNameMultiValueCF = ABRecordCopyValue(person, kABPersonLastNameProperty);
CFStringRef firstNmaeMultiValueCF = ABRecordCopyValue(person, kABPersonFirstNameProperty);
CFStringRef middleNmaeMultiValueCF = ABRecordCopyValue(person, kABPersonMiddleNameProperty);
NSString *lastNameMultiValue = (__bridge NSString *)lastNameMultiValueCF;
NSString *firstNmaeMultiValue = (__bridge NSString *)firstNmaeMultiValueCF;
NSString *middleNmaeMultiValue = (__bridge NSString *)middleNmaeMultiValueCF;
NSString *name = [NSString stringWithFormat:@"%@%@%@",(![lastNameMultiValue length])?@"":lastNameMultiValue, (![middleNmaeMultiValue length])?@"":middleNmaeMultiValue, (![firstNmaeMultiValue length])?@"":firstNmaeMultiValue];
if (lastNameMultiValueCF != NULL)CFRelease(lastNameMultiValueCF);
if (firstNmaeMultiValueCF != NULL)CFRelease(firstNmaeMultiValueCF);
if (middleNmaeMultiValueCF != NULL)CFRelease(middleNmaeMultiValueCF);
CFDataRef anAvatarCF = ABPersonCopyImageDataWithFormat(person, kABPersonImageFormatThumbnail);
NSData *anAvatarData = (__bridge NSData *)anAvatarCF;
UIImage *anAvatar = [UIImage imageWithData:anAvatarData];
if (anAvatarCF != NULL)CFRelease(anAvatarCF);
NSDictionary *aPersonDict = [NSDictionary dictionaryWithObjectsAndKeys:name, @"name", [phoneStrArr componentsJoinedByString:@"; "], @"phoneNumber", [emailStrArr componentsJoinedByString:@"; "], @"email", anAvatar, @"avatar", nil];
[contactMutArr addObject:aPersonDict];
NSLog(@"------phoneStrArr :%@",phoneStrArr);
NSString *enPhoneNumber = @"";
if (phoneStrArr) {
enPhoneNumber = [EncryptWithMD5 encryptWithMD5: [phoneStrArr componentsJoinedByString:@"; "]];
}
[mStrOfContacts appendString:enPhoneNumber];
[mStrOfContacts appendString:@", "];
if (phoneMultiValue != NULL)CFRelease(phoneMultiValue);
if (emailMultiValue != NULL)CFRelease(emailMultiValue);
}
}else{
for (id aPerson in contactsInAddressBook) {
ABRecordRef person = (__bridge ABRecordRef)(aPerson);
ABMultiValueRef phoneMultiValue = ABRecordCopyValue(person, kABPersonPhoneProperty);
ABMultiValueRef emailMultiValue = ABRecordCopyValue(person, kABPersonEmailProperty);
int countEmail = 0;
NSMutableArray *emailStrArr;
NSMutableArray *phoneStrArr;
if (emailMultiValue != NULL) {
countEmail = ABMultiValueGetCount(emailMultiValue);
}
if (countEmail>0) {
emailStrArr = [NSMutableArray array];
for (int i = 0; i < countEmail; i++) {
CFStringRef anEmailCF = ABMultiValueCopyValueAtIndex(emailMultiValue, i);
NSString *anEmail = (__bridge NSString *)anEmailCF;
[emailStrArr addObject:anEmail];
if (anEmailCF != NULL)CFRelease(anEmailCF);
}
}
int count = ABMultiValueGetCount(phoneMultiValue);
if (count > 0) {
phoneStrArr = [NSMutableArray array];
for (int i = 0; i < count; i++) {
CFStringRef anPhoneCF = ABMultiValueCopyValueAtIndex(phoneMultiValue, i);
NSString *anPhone = (__bridge NSString *)anPhoneCF;
NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet];
NSString *anPhonePureNumber = [[anPhone componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];
[phoneStrArr addObject:anPhonePureNumber];
if (anPhoneCF != NULL)CFRelease(anPhoneCF);
}
}
CFStringRef lastNameMultiValueCF = ABRecordCopyValue(person, kABPersonLastNameProperty);
CFStringRef firstNmaeMultiValueCF = ABRecordCopyValue(person, kABPersonFirstNameProperty);
CFStringRef middleNmaeMultiValueCF = ABRecordCopyValue(person, kABPersonMiddleNameProperty);
NSString *lastNameMultiValue = (__bridge NSString *)lastNameMultiValueCF;
NSString *firstNmaeMultiValue = (__bridge NSString *)firstNmaeMultiValueCF;
NSString *middleNmaeMultiValue = (__bridge NSString *)middleNmaeMultiValueCF;
NSString *name = [NSString stringWithFormat:@"%@%@%@", (![firstNmaeMultiValue length])?@"":firstNmaeMultiValue, (![middleNmaeMultiValue length])?@"":middleNmaeMultiValue,(![lastNameMultiValue length])?@"":lastNameMultiValue];
if (lastNameMultiValueCF != NULL)CFRelease(lastNameMultiValueCF);
if (firstNmaeMultiValueCF != NULL)CFRelease(firstNmaeMultiValueCF);
if (middleNmaeMultiValueCF != NULL)CFRelease(middleNmaeMultiValueCF);
CFDataRef anAvatarCF = ABPersonCopyImageDataWithFormat(person, kABPersonImageFormatThumbnail);
NSData *anAvatarData = (__bridge NSData *)anAvatarCF;
UIImage *anAvatar = [UIImage imageWithData:anAvatarData];
if (anAvatarCF != NULL)CFRelease(anAvatarCF);
NSDictionary *aPersonDict = [NSDictionary dictionaryWithObjectsAndKeys:name, @"name", [phoneStrArr componentsJoinedByString:@"; "], @"phoneNumber", [emailStrArr componentsJoinedByString:@"; "], @"email", anAvatar, @"avatar", nil];
[contactMutArr addObject:aPersonDict];
NSString *enPhoneNumber = [EncryptWithMD5 encryptWithMD5: [phoneStrArr componentsJoinedByString:@"; "]];
[mStrOfContacts appendString:enPhoneNumber];
[mStrOfContacts appendString:@", "];
if (phoneMultiValue != NULL)CFRelease(phoneMultiValue);
if (emailMultiValue != NULL)CFRelease(emailMultiValue);
}
}
self.contactArr = [[NSArray alloc] initWithArray: contactMutArr];
strOfContacts = [NSString stringWithString:mStrOfContacts];
}
编辑2
-(void)beginFetchContacts{
// Request authorization to Address Book
ABAddressBookRef addressBookRef = NULL;
if (ABAddressBookRequestAccessWithCompletion) {
CFErrorRef *aError=nil;
addressBookRef = ABAddressBookCreateWithOptions(NULL, aError);
if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusNotDetermined) {
ABAddressBookRequestAccessWithCompletion(addressBookRef, ^(bool granted, CFErrorRef error) {
// First time access has been granted, add the contact
if (granted) {
[self dofetchContacts:addressBookRef];
}else{
// [self alertActionSwitchOnTheContactsAccess];
[self buttonCancelPressed:nil];
}
});
}
else if (ABAddressBookGetAuthorizationStatus() == kABAuthorizationStatusAuthorized) {
// The user has previously given access, add the contact
[self dofetchContacts:addressBookRef];
}
}else{
addressBookRef = ABAddressBookCreate();
[self dofetchContacts:addressBookRef];
}
if (addressBookRef != NULL)CFRelease(addressBookRef);
}
最佳答案
我看到崩溃的线程是“com.apple.root.default-priority”
ABAddressBook 不是线程安全的,因此如果您从两个不同的线程调用它,它抛出异常并使应用程序崩溃。
即使您总是将调用分派(dispatch)给 DISPATCH_QUEUE_PRIORITY_DEFAULT,它也可能在两个不同的线程上运行,因为 DISPATCH_QUEUE_PRIORITY_DEFAULT 不是串行队列。
使用它来创建您的串行队列,该队列分派(dispatch)到 DISPATCH_QUEUE_PRIORITY_DEFAULT:
dispatch_queue_t abQueue = dispatch_queue_create("myabqueue", DISPATCH_QUEUE_SERIAL);
dispatch_set_target_queue(abQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0));
请记住将所有对地址簿的调用分派(dispatch)(同步或异步)到此队列。
编辑:
您似乎在传递给函数 ABAddressBookRequestAccessWithCompletion
的完成处理程序 block 中调用 dofetchContacts。请务必在主线程上分派(dispatch)此调用!
文档说:
The completion handler is called on an arbitrary queue. If your app uses an address book throughout the app, you are responsible for ensuring that all usage of that address book is dispatched to a single queue to ensure correct thread-safe operation.
关于ios - 用户访问通讯录时的崩溃报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16514308/
@After public void afterScenario() { if (ScenarioManager.getScenario().isFailed()) {
我已将 BIRT 报告集成到 Grails 中并设计了一份报告。我的 grails 应用程序中有一个名为 startPeriod (仅限月份和年份)的参数,我想将其传递给 BIRT。然后 BIRT 调
我有一些 Oracle 报告 (.rdf),正在考虑将其转换为 BIRT 报告。有没有办法将 .rdf 文件转换为 BIRT 报告设计文件? 最佳答案 完全自动化的解决方案可能是不可能的。您可以部分自
当 gcc 4.1(使用 gcov)下一行: p = 新类; 报告为 100% 分支覆盖率 为什么? 因为启用了异常处理!!! 为了解决此问题,请指定: -fno-exceptions 在 g++
真的有好 免费 BugZilla 报告工具?我发现 Web 界面上的默认搜索选项太有限了。我最大的问题是缺少 Order By 选项(一次只有 1 个字段,可供选择的字段集非常有限)。我已经做了一些谷
是否可以在 CFMX7 上运行 ColdFusion Report builder 生成的报告? 更明确地说,是否可以将 CF7 中的报告生成引擎更改为 CF8? 最佳答案 我猜这可能很难做到。我记得
根据Lucintel发布的新市场报告,智能家居市场的未来看起来很有吸引力,在家用安全、家电、娱乐、照明、HVAC、医疗保健和厨房应用中将带来许多机遇。 由于COVID-19导致的全球经济衰退,
PHPCodeSniffer 是否生成 HTML 报告? 如果不是呢?怎么办? 目前,我可以运行 PHPCodeSniffer,但它只生成 XML 文件并在终端中显示结果。 如何在 phpunit 中
我在一个包中添加了一个简单的测试。 按照手册中的建议,我尝试让 PHPUnit 加载配置: phpunit -c /app phpunit.xml 看起来像这样:
我有两个从 csv 文件加载的数据框。基本上来自不同的环境但格式/列相似,它们的行/值可能有所不同。我想找到差异并在新的数据框中创建它们。两个数据框也将具有相同的顺序。我有 100 个要比较的文件。提
我想看看是否有办法通过 javadoc 在我的 junit 报告中包含“描述性文本”。 JUnit 4 似乎不像 TestNG 那样支持 @Test 注释的“描述”属性。 到目前为止,我所研究的只有一
我正在使用操作、 Controller 、servlet struts 框架编写 Excel 报告。该报告非常拥挤,已经有大约 10 个单独的查询。由于报告发生变化,我需要再添加大约 10 个查询。有
在放弃 Syleam 的 openerp jasper 模块后,我在 Nan Tic 的 jasper_reports 模块上苦苦挣扎。 它一直给我一个错误: File "C:\Program Fil
我希望创建一个简单的日历。每天由编码器生成条目计数并以日历样式查看。如一月、二月等。或按月显示全年。 database have date_added and encoder columns 我在将它
我必须为报告创建 MySQL 查询。 我有一个表history,它记录产品订单的状态更改。我有订单生命周期(订单流程)的以下状态:新、已确认、正在处理、已发货、已交付、已取消、已退回。订单不一定遵循此
如何将多个查询合并为一个? 例如: //Successful Sales: SELECT username, count(*) as TotalSales, sum(point) as Points
MySQL 优化技术的新手。请找到下面的 mysqltuner.pl 报告,并建议我应该更改 my.cnf 中的哪些变量以优化性能。 还有一个问题- 我无法在我的 my.cnf 中找到一些变量,例如
我想知道,我想将我的 Swing Worker 的某种形式的进度报告回主线程,以便我的界面可以使用随着进度增加而变化的标签进行更新,例如 checking 1/6... checking 2/6...
我正在尝试在“报告”>“销售”下运行 Magento Paypal 结算报告,但每次我尝试运行该报告时,我都会收到消息“由于配置为空,无法获取任何内容” 我查看了“系统”>“配置”>“销售”>“付款方
我想要一个工具来帮助创建 sql 查询(对于非 IT 人员),例如 dbforge。 我希望我们的非 IT 人员(例如运营)创建他们自己的 sql 查询。 我的第二个目标是让他们能够按需执行这些查询。
我是一名优秀的程序员,十分优秀!