sigabrt on filteredArrayUsingPredicate

可紊 提交于 2019-12-06 12:07:35

问题


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_throwto 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!