我使用地址簿框架为我的应用程序,我有崩溃的代码。代码如下所示
+(NSMutableArray *)getcontactdetails
{
[self current_function_name:@"Inside getcontactdetails"];
NSMutableArray *list = [[NSMutableArray alloc] init];
ABAddressBookRef addressBook;
CFArrayRef allSources;
addressBook = ABAddressBookCreate();
ABRecordRef source = ABAddressBookCopyDefaultSource(addressBook);
allSources = ABAddressBookCopyArrayOfAllPeopleInSourceWithSortOrdering(addressBook, source, kABPersonFirstNameProperty);
CFIndex nPeople = ABAddressBookGetPersonCount(addressBook);
if(nPeople != 0){
for (CFIndex i = 0; i < nPeople; i++)
{
//common field
NSString *basic_email =[[NSString alloc] init] ;
NSString *basic_mobile =[[NSString alloc] init] ;
//personal filed
NSString *Home_email =[[NSString alloc] init] ;
NSString*home_mobile =[[NSString alloc] init] ;
NSString*home_address =[[NSString alloc] init];
//business filed
NSString *work_email =[[NSString alloc] init] ;
NSString*work_mobile =[[NSString alloc] init] ;
NSString *work_address =[[NSString alloc] init] ;
contact_details *phone_book_data=[[contact_details alloc] init];
ABRecordRef aSource = CFArrayGetValueAtIndex(allSources,i);
// Fetch all groups included in the current source
NSString *first_name = (NSString*)ABRecordCopyValue(aSource, kABPersonFirstNameProperty);
if (![first_name isEqualToString:@"(null)"]){
phone_book_data.FirstName=[NSString stringWithFormat:@"%@",first_name];
}
NSLog(@"last_name:-%@",first_name);
NSString *last_name=(NSString*)ABRecordCopyValue(aSource, kABPersonLastNameProperty);
if ([last_name isEqualToString:@"(null)"] || last_name == nil || last_name.length == 0) {
phone_book_data.LastName=[NSString stringWithFormat:@""];
}
else{
phone_book_data.LastName=[NSString stringWithFormat:@"%@",last_name];
}
NSLog(@"last_name:-%@",last_name);
NSString *company_name=(NSString*)ABRecordCopyValue(aSource, kABPersonOrganizationProperty);
NSLog(@"companyname:-%@",company_name);
NSString *job_title=(NSString*)ABRecordCopyValue(aSource, kABPersonJobTitleProperty);
NSLog(@"jobtitle:-%@",job_title);
ABMultiValueRef address =(NSString*)ABRecordCopyValue(aSource, kABPersonAddressProperty);
NSString* addLabel;
for(CFIndex i = 0; i < ABMultiValueGetCount(address); i++) {
addLabel=(NSString*)ABMultiValueCopyLabelAtIndex(address, i);
if ([addLabel isEqualToString:(NSString*)kABWorkLabel])
{
work_address=@"exist";
}
if ([addLabel isEqualToString:(NSString*)kABHomeLabel])
{
home_address=@"exist";
}
}
NSLog(@"work_address:-%@",work_address);
NSLog(@"home_address:-%@",home_address);
ABMultiValueRef phones =(NSString*)ABRecordCopyValue(aSource, kABPersonPhoneProperty);
NSString* mobileLabel;
for(CFIndex i = 0; i < ABMultiValueGetCount(phones); i++) {
mobileLabel = (NSString*)ABMultiValueCopyLabelAtIndex(phones, i);
if([mobileLabel isEqualToString:(NSString *)kABPersonPhoneMobileLabel])
{
home_mobile = [(NSString*)ABMultiValueCopyValueAtIndex(phones, i) retain];
}
if ([mobileLabel isEqualToString:(NSString*)kABPersonPhoneIPhoneLabel])
{
basic_mobile = [(NSString*)ABMultiValueCopyValueAtIndex(phones, i)retain];
}
if([mobileLabel isEqualToString:(NSString *)kABPersonPhoneMainLabel])
{
work_mobile = [(NSString*)ABMultiValueCopyValueAtIndex(phones, i)retain];
}
}
NSLog(@"home_mobile:-%@",home_mobile);
NSLog(@"basic_mobile:-%@",basic_mobile);
NSLog(@"work_mobile:-%@",work_mobile);
ABMultiValueRef email = ABRecordCopyValue(aSource, kABPersonEmailProperty);
NSString* email_lbl;
for(CFIndex i = 0; i < ABMultiValueGetCount(email); i++) {
email_lbl = (NSString*)ABMultiValueCopyLabelAtIndex(email, i);
if([email_lbl isEqualToString:(NSString *)kABHomeLabel])
{
Home_email = [(NSString*)ABMultiValueCopyValueAtIndex(email, i)retain];
}
if([email_lbl isEqualToString:(NSString *)kABWorkLabel])
{
work_email = [(NSString*)ABMultiValueCopyValueAtIndex(email, i)retain];
}
if([email_lbl isEqualToString:(NSString *)kABOtherLabel]){
basic_email = [(NSString*)ABMultiValueCopyValueAtIndex(email, i)retain];
}
}
NSLog(@"Home_email:-%@",Home_email);
NSLog(@"work_email:-%@",work_email);
NSLog(@"basic_email:-%@",basic_email);
if ([company_name isEqualToString:@""] || [company_name isEqualToString:@"(null)"] || company_name.length == 0) {
if ([job_title isEqualToString:@""] || [job_title isEqualToString:@"(null)"] || job_title.length == 0) {
if ([work_address isEqualToString:@""] || [work_address isEqualToString:@"(null)"] || work_address.length == 0) {
if ([work_mobile isEqualToString:@""] || [work_mobile isEqualToString:@"(null)"] || work_mobile.length == 0) {
if ([work_email isEqualToString:@""] || [work_email isEqualToString:@"(null)"] || work_email.length == 0) {
phone_book_data.Type=[NSString stringWithFormat:@"personal"];
}
else{
phone_book_data.Type=[NSString stringWithFormat:@"business"];
}
}
else{
phone_book_data.Type=[NSString stringWithFormat:@"business"];
}
}
else
{
phone_book_data.Type=[NSString stringWithFormat:@"business"];
}
}
else{
phone_book_data.Type=[NSString stringWithFormat:@"business"];
}
}
else{
phone_book_data.Type=[NSString stringWithFormat:@"business"];
}
if ([phone_book_data.Type isEqualToString:@"business"])
{
if ([work_mobile isEqualToString:@"(null)"] ||[work_mobile isEqualToString:@""] || work_mobile == nil || work_mobile.length == 0) {
if ([basic_mobile isEqualToString:@"(null)"] || basic_mobile == nil || basic_mobile.length == 0) {
phone_book_data.MobileNumber = @"";
}
else{
phone_book_data.MobileNumber=[NSString stringWithFormat:@"%@",basic_mobile];
}
}
else{
phone_book_data.MobileNumber=[NSString stringWithFormat:@"%@",work_mobile];
}
if ([work_email isEqualToString:@"(null)"] || work_email == nil || work_email.length == 0)
{
if ([basic_email isEqualToString:@"(null)"] || basic_email == nil || basic_email.length == 0) {
phone_book_data.emailaddress=@"";
}
else{
if ([basic_email rangeOfString:@"gmail"].location != NSNotFound || [basic_email rangeOfString:@"yahoo"].location != NSNotFound || [basic_email rangeOfString:@"hotmail"].location != NSNotFound ||[basic_email rangeOfString:@"aol"].location != NSNotFound) {
phone_book_data.emailaddress=basic_email;
}
else{
phone_book_data.emailaddress=@"";
}
}
}
else{
if ([work_email rangeOfString:@"gmail"].location == NSNotFound || [work_email rangeOfString:@"yahoo"].location == NSNotFound || [work_email rangeOfString:@"hotmail"].location == NSNotFound ||[work_email rangeOfString:@"aol"].location == NSNotFound) {
phone_book_data.emailaddress=@"";
}
else{
phone_book_data.emailaddress=work_email;
}
}
}
else{
if ([home_mobile isEqualToString:@"(null)"] || home_mobile == nil || home_mobile.length == 0) {
if (![basic_mobile isEqualToString:@"(null)"] || basic_mobile != nil || basic_mobile.length != 0) {
phone_book_data.MobileNumber=[NSString stringWithFormat:@"%@",basic_mobile];
}
else{
phone_book_data.MobileNumber = @"";
}
}
else{
phone_book_data.MobileNumber=[NSString stringWithFormat:@"%@",home_mobile];
}
if ([Home_email isEqualToString:@"(null)"] || Home_email == nil || Home_email.length == 0)
{
if ([basic_email isEqualToString:@"(null)"] || basic_email == nil || basic_email.length == 0) {
phone_book_data.emailaddress=@"";
}
else{
phone_book_data.emailaddress=basic_email;
}
}
else{
phone_book_data.emailaddress=Home_email;
}
}
if(ABPersonHasImageData(aSource)){
phone_book_data.contact_image = [UIImage imageWithData:(NSData *)ABPersonCopyImageData(aSource)];
}else{
phone_book_data.contact_image = [UIImage imageNamed:@"blank_image.png"];
}
phone_book_data.isselected=TRUE;
[list addObject:phone_book_data];
[phone_book_data release];
phone_book_data=nil;
}
}
CFRelease(allSources);
[self current_function_name:@"Finished getcontactdetails"];
return list;
}
现在我在车祸报告中发现了这个错误。
事故标识符:C28DCEAD-5DCD-469B-9349-46F59A92B25E
CrashReporter密钥:e1b5c8f591e28608a399ebe58d339df84ab3ae52
硬件型号:iPhone3,1
过程: intooch[163]
路径:/var/mobile/Applications/CB8405B7-8B2A-4226-9134-D99AC5474776/intooch。app/intooch
标识符:intooch
版本:???(???)
代码类型:ARM(本机)
父进程:已启动[1]
日期/时间:2012-09-09 22:45:57.023-0700
操作系统版本:iPhoneOS5.1。1(9B208)
报告版本:104
异常类型:EXC_BAD_ACCESS(SIGSEGV)
异常代码:0x0000003d处的内核地址无效
崩溃的线程: 4
线程0名称:调度队列:com.apple.main线程
线程0:
0 libu系统内核。动态库0x365ef004 0x365ee000 4100
1 libu系统内核。动态库0x365ef1fa 0x365ee000 4602
2 CoreFoundation 0x369bd3ec 0x36930000 578540
3 CoreFoundation 0x369bc0ea 0x36930000 573674
4 CoreFoundation 0x3693f49e 0x36930000 62622
5 CoreFoundation 0x3693f366 0x36930000 62310
6图形服务0x34b06432 0x34b02000 17458
7 UIKit 0x34be8cce 0x34bb7000 203982
8 intooch 0x00049648 0x45000 17992
9 intooch 0x00047138 0x45000 8504
线程1名称:调度队列:com。苹果图书馆调度经理
线程1:
0libsystem_kernel.dylib0x365ef3a8 0x365ee000 5032
1.图书馆调度。动态库0x3741cea4 0x37410000 52900
2.调度。动态库0x3741cbc2 0x37410000 52162
线程2名称:WebThread
线程2:
0 libu系统内核。动态库0x365ef004 0x365ee000 4100
1 libu系统内核。动态库0x365ef1fa 0x365ee000 4602
2 CoreFoundation 0x369bd3ec 0x36930000 578540
3 CoreFoundation 0x369bc124 0x36930000 573732
4 CoreFoundation 0x3693f49e 0x36930000 62622
5 CoreFoundation 0x3693f366 0x36930000 62310
6 WebCore 0x31932c9c 0x31889000 695452
7libsystem_c.dylib0x32f3772e 0x32f29000 59182
8 libsystem_c.dylib 0x32f375e8 0x32f29000 58856
线程3:
0libsystem_kernel.dylib0x365ffcd4 0x365ee000 72916
1 libsystem_c.dylib 0x32f31f36 0x32f29000 36662
2 libsystem_c.dylib 0x32f31cc8 0x32f29000 36040
线程4崩溃:
0应用程序支持0x34937e8a 0x3492e000 40586
1 AppSupport 0x3493806e 0x3492e000 41070
2地址簿0x315b8edc 0x315a7000 73436
3 intooch 0x00058618 0x45000 79384
4 InToch 0x0004a0b6 0x45000 20662
5基金会0x32591a7a 0x32581000 68218
6基金会0x3262558A 0X32581000 673162
7libsystem_c.dylib0x32f3772e 0x32f29000 59182
8 libsystem_c.dylib 0x32f375e8 0x32f29000 58856
线程5:
0libsystem_kernel.dylib0x365ffcd4 0x365ee000 72916
1 libsystem_c.dylib 0x32f31f36 0x32f29000 36662
2 libsystem_c.dylib 0x32f31cc8 0x32f29000 36040
线程6名称:com。苹果NSURLConnectionLoader
线程6:
0 libu系统内核。动态库0x365ef004 0x365ee000 4100
1 libu系统内核。动态库0x365ef1fa 0x365ee000 4602
2 CoreFoundation 0x369bd3ec 0x36930000 578540
3 CoreFoundation 0x369bc124 0x36930000 573732
4 CoreFoundation 0x3693f49e 0x36930000 62622
5 CoreFoundation 0x3693f366 0x36930000 62310
6基金会0x32591bb2 0x32581000 68530
7基金会0x32591A7A 0x32581000 68218
8基金会0x3262558A 0X32581000 673162
9 libsystem_c.dylib 0x32f3772e 0x32f29000 59182
10 libsystem_c.dylib 0x32f375e8 0x32f29000 58856
线程7名称:com。苹果CFSocket。私有的
线程7:
0libsystem_kernel.dylib0x365ff570 0x365ee000 71024
1 CoreFoundation 0x369c163a 0x36930000 595514
2 libsystem_c.dylib 0x32f3772e 0x32f29000 59182
3 libsystem_c.dylib 0x32f375e8 0x32f29000 58856
线程4在ARM线程状态下崩溃:
r0: 0x00000015 r1: 0x00000000 r2: 0x00000002 r3: 0x002ec510
r4: 0x00000000 r5: 0x0000000a r6: 0x0010a8e8 r7: 0x03f4ac9c
r8: 0x37cfef2f r9: 0x00000009 r10: 0x002ec510 r11: 0x00000122
ip: 0x3e61d63c sp: 0x03f4ac88 lr: 0x34938075 pc: 0x34937e8a
CPSR: 0x00000030
我是如何修复这个错误的?
提前感谢。。。
找到问题原因的最佳方法取决于您是否仍在开发并拥有代码,或者这是否是来自iTunes的崩溃报告。
虽然这里有一份关于ARM寄存器的详细苹果文档http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARMv6FunctionCallingConventions.html但它并没有真正帮助找到问题。
如果您有代码并且仍在开发中,我建议您需要在代码中添加nslog和/或进行一些调试。
如果是iTunes的崩溃报告,最好遵循苹果的崩溃报告指南http://developer.apple.com/library/ios/#technotes/tn2151/_index.html.
这是苹果描述的主要思想:
如果您通过Xcode的“管理器”窗口从设备上获取崩溃日志,那么几秒钟后它们将自动为您标记。否则,您将需要用符号表示。通过将文件导入Xcode管理器,您可以自己崩溃文件。打开Xcode管理器,选择“设备”选项卡,在侧边栏顶部的“库”下选择“设备日志”,单击“导入”按钮并选择。崩溃文件。
基本上,在这种情况下,您所需要做的就是将崩溃报告拖放到xCode中,但请确保您拥有dSym文件,以便xCode可以使用应用程序版本的正确版本来复制崩溃报告。要做到这一点,您需要“构建并归档”每个分布式应用程序版本!ps描述所有细节的视频在第317课时。。。
我想发送和接收数据报套接字,但遇到了异常。我传递了要通信的服务器的正确IP地址和正确的端口号。 请帮帮我。
问题内容: 我了解到,哈希码是一个唯一标识参考号,它是一个十六进制数。 我的疑问是,参考数字代表对象的内存地址吗? 例如: 这段代码会返回我对象的内存地址吗? 问题答案: 哈希码不是唯一的标识。它只是一个数字,可以帮助您区分对象。两个不同的对象可能具有相同的哈希码,这很好。 HashCode特征: 如果obj1和obj2相等,则它们必须具有相同的哈希码。 如果obj1和obj2具有相同的哈希码,则
本章主要列出 JA 的错误代码,供开发者参考 异常代码 描述 原因 解决方案 2000 Success - - 5000 Failure 多为系统异常,如 JA 本身的 BUG,或者其他原因 请参考控制台异常栈 5001 Not Implemented 方法未实现 ① 针对自定义的 oauth 平台,请检查你的代码,是否存在未实现必要接口的问题; ② 针对 JA 内置的平台,说明该平台的某个方法暂
80386在实地址模式下报告的异常与保护模式大不相同。表14-1详细描述了实地址模式异常。
我不熟悉java、Junit和jacoco。我正在做下面的异常处理。我也在捕获异常类,以防该方法抛出之前未捕获的任何其他异常。 在Junit测试中,尝试如下。当我有运行时的任何异常时,我抛出的总是运行时异常捕获块本身,除非我抛出异常。我可以尝试其他哪个选中的异常,使其进入异常捕获块。因此,我无法获得所需的代码覆盖率。 谢谢你的帮助。
问题内容: 当我经历了以下块的Linux的字符设备驱动程序代码,我发现结构的指针在。 我想知道指向的结构及其完整元素。 此结构有什么作用? 问题答案: 它是指向当前进程(即已发出系统调用的进程)的指针。 从文档: 当前过程 尽管内核模块不像应用程序那样顺序执行,但是内核执行的大多数操作都与特定进程有关。内核代码可以通过访问全局项current来了解驱动它的当前进程,该全局项current是指向st