【发布时间】:2012-01-05 04:37:01
【问题描述】:
当从通讯簿中获取电话号码返回我的应用程序时,如果我错误地获取了一些地址或除电话号码之外的任何其他内容,try catch final 中的代码会给出以下但没有捕获它,任何想法提前表示赞赏:
*** -[CFDictionary length]: message sent to deallocated instance 0x6a4db70
代码:
strContact = (NSString *)phone; CFRelease(phone);
// NSLog(@"%@", strContact);
CFRelease(multi);
name = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty);
NSRegularExpression *regex = [[[NSRegularExpression alloc] initWithPattern:@"[a-zA-Z]" options:0 error:NULL] autorelease];
// Assuming you have some NSString myString.
NSUInteger matches = [regex numberOfMatchesInString:strContact options:0 range:NSMakeRange(0, [strContact length])];
【问题讨论】:
-
请在问题中输入一些代码
-
可能是另一个 catch 块先捕获它吗?
-
strContact = (NSString *)phone; CFRelease(电话); // NSLog(@"%@", strContact); CFR 释放(多); name = (NSString *)ABRecordCopyValue(person, kABPersonFirstNameProperty); NSRegularExpression *regex = [[[NSRegularExpression alloc] initWithPattern:@"[a-zA-Z]" options:0 error:NULL] autorelease]; // 假设你有一些 NSString
myString。 NSUInteger 匹配 = [regex numberOfMatchesInString:strContact options:0 range:NSMakeRange(0, [strContact length])]; -
我在 NSMakeRange 中遇到错误
-
代码中的 try/catch 块在哪里?
标签: iphone objective-c xcode exception try-catch