问题
I'm a noob and trying to convert an example from a book into an app I can use.
The sample app is a modified version of the contacts application and it works.
I've done some further modification, and the search no longer works. It sigabrts on the following line
self.filteredAnswercards = [flattenedArray
filteredArrayUsingPredicate:predicate];
I'm stumped. my head is bloody from beating it against my keyboard.
ANY help is massively appreciated.
Thanks.
回答1:
My suggestion was to wrap the line that crashes inside a @try/@catch block and, inside the catch, log the exception and the result of the exception's callStackSymbols method.
For the record, part of the problem with the 4.x versions of Xcode is that they are much worse than 3.x versions at telling you where an exception is coming from. For this reason, getting familiar with tricks that make a program or the debugger tell you what you need to know is very important.
回答2:
I would guess that predicate
is nil. Where did you assign it? Or did you never assign it?
回答3:
Very hard to say without seeing more code. Sigabort generally means an exception has been thrown. You can put a break point in objc_exception_throw
to get a back trace which should help highlight the cause.
If you get NO new info with the above, others have said that a full reboot of the computer can help... but I have not had a situation where I could verify this.
---- edit based on comments -----
It sounds like filteredAnswercards
is nil, that will definitely cause a Sigabort. Allocate that array properly and you should be good to go.
来源:https://stackoverflow.com/questions/10309541/sigabrt-on-filteredarrayusingpredicate