我正在我的NSMutableArray中進行某種搜索,但我經常獲得SIGABRT。我是新來的Objective-C,所以我不知道如果我錯過了一些重要的東西在這裏...當試圖比較某些字符串時獲取SIGABRT
-(IBAction)findButtonPushed:(id)sender
{
Data *stuff = [Data getInstance];
[stuff.results removeAllObjects];
NSMutableArray *tempResults = [[NSMutableArray alloc] init];
for (Company *company in stuff.companies) {
if ([company.Description rangeOfString:[sbWhat text] options:NSCaseInsensitiveSearch].location != NSNotFound
|| [company.Name rangeOfString:[sbWhat text] options:NSCaseInsensitiveSearch].location != NSNotFound
|| [company.Url rangeOfString:[sbWhat text] options:NSCaseInsensitiveSearch].location != NSNotFound
|| [company.FirstName rangeOfString:[sbWhat text] options:NSCaseInsensitiveSearch].location != NSNotFound
|| [company.LastName rangeOfString:[sbWhat text] options:NSCaseInsensitiveSearch].location != NSNotFound
|| [company.Keywords rangeOfString:[sbWhat text] options:NSCaseInsensitiveSearch].location != NSNotFound) {
[tempResults addObject:company];
}
}
if (![[sbWhere text] isEqualToString:@""]) {
for (Company *company in tempResults) {
if ([company.Street rangeOfString:[sbWhere text] options:NSCaseInsensitiveSearch].location != NSNotFound
|| [company.City rangeOfString:[sbWhere text] options:NSCaseInsensitiveSearch].location != NSNotFound
|| [company.ZipCode rangeOfString:[sbWhere text] options:NSCaseInsensitiveSearch].location != NSNotFound
|| [company.State rangeOfString:[sbWhere text] options:NSCaseInsensitiveSearch].location != NSNotFound
|| [company.AddressPt1 rangeOfString:[sbWhere text] options:NSCaseInsensitiveSearch].location != NSNotFound
|| [company.AddressPt2 rangeOfString:[sbWhere text] options:NSCaseInsensitiveSearch].location != NSNotFound
|| [company.Country rangeOfString:[sbWhere text] options:NSCaseInsensitiveSearch].location != NSNotFound) {
[stuff.results addObject:company];
}
}
}
else{
stuff.results = tempResults;
}
[self performSegueWithIdentifier:@"ShowResults" sender:self];
}
順便說一句,sbWhere和sbWhat是UISearchBars
我在這兩個如果獲取SIGABRT聲明。我通過解析json字符串獲得的公司。
我喜歡那些條件表達式 – 2012-06-28 19:07:52
神聖的上帝,這是一個很大的邏輯OR的。 – CodaFi
在SIGABRT之前打印到控制檯的整個錯誤消息是什麼?我打賭美元甜甜圈就像「發送到實例0xDEADBEEF的無法識別的選擇器」。 –