在发布配置中构建时出现分段错误,但在调试配置中没有。
此代码是在运行时加载的包。崩溃本身发生在执行任何我之前(暗示编译器正在生成格式错误的二进制文件,几乎可以肯定是因为我的代码中存在问题)。崩溃发生在这个函数中:paranoid_check_one_class
下面的代码没有问题,但是如果我取消注释被注释掉的两行,那么我就会崩溃。(我可以注释掉firstName
,lastName
或者company
让它工作,它只是不喜欢这三个)
-(NSArray *)specifiersForContacts {
NSMutableArray *contactSpecs = [NSMutableArray array];
ABAddressBookRef book = ABAddressBookCreateWithOptions(NULL, NULL);
for (NSNumber *contactID in [self contacts]) {
ABRecordRef contact = ABAddressBookGetPersonWithRecordID(book,[contactID intValue]);
NSString *firstName = (NSString *)ABRecordCopyValue(contact, kABPersonFirstNameProperty);
NSString *lastName = (NSString *)ABRecordCopyValue(contact, kABPersonLastNameProperty);
//NSString *company = (NSString *)ABRecordCopyValue(contact, kABPersonOrganizationProperty);
NSString *fullName = [NSString stringWithFormat:@"%@ %@", firstName ?: @"", company ?: @""];
PSSpecifier *contactSpec = [PSSpecifier preferenceSpecifierNamed:fullName
target:self
set:NULL
get:NULL
detail:Nil
cell:13
edit:Nil];
[contactSpec setValues:@[contactID]];
[contactSpec setProperty:[NSNumber numberWithInt:1] forKey:@"alignment"];
[firstName release];
[lastName release];
//[company release];
[contactSpecs addObject:contactSpec];
}
return [[contactSpecs copy] autorelease];
}