iOS App error and its causing the app to crash [closed] - ios

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I got this error while running my app for test:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x30d48fd3 0x3b5c1ccf 0x30c82a8b 0x30c8c391 0x1038ab 0x335d45a7 0x335d3efb 0x335ce58b 0x3356a709 0x33569871 0x335cdcc9 0x35bd6aed 0x35bd66d7 0x30d13ab7 0x30d13a53 0x30d12227 0x30c7cf0f 0x30c7ccf3 0x335ccef1 0x335c816d 0x1053c1 0x3baceab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
Causing the app to crash

Without more context, it'll be tough to give a good answer. That said, inserting a nil object into an NSArray-type class (including NSMutableArray) will cause an e exception to be thrown. If you need an "empty" value in an array, use [NSNull null].
To debug this, try enabling an exception breakpoint in Xcode. Here's how:
On the lefthand panel, choose the second icon from the right. That's the breakpoints panel.
On the bottom corner, there's a little plus. Click it.
In the menu, choose "Add Exception Breakpoint"
Run your code. When it crashes, it'll show you the line that's crashing, as well as a stack trace.

You are trying to insert a nil object. If you want to add nill object you should add as following. You can't add it directly
[array addObject:[NSNull null]];

You can't add nil to an array (as it holds pointers to the objects) so it crashes. If you need to store nil in an NSArray use NSNull which simply wraps nil into an array.

Related

Where do I get a readable stack trace in Xcode?

The following is the exception I get from iOS. It looks ridiculously unreadable (my brain is screaming wtf ten thousand miles per second). So this can’t be right. When I am developing for android, and I get an exception, the stack trace is completely readable, no magic such as 0x187d27bc8. So am I looking at the wrong window? Where in Xcode to I go to find a readable version of my stack trace? In eclipse there is a line number I can click on to get to the exact line that caused the error.
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x1835a6084 0x193b840e4 0x18348f300 0x18349b5b8 0x100185c94 0x100185af4 0x10009f7b4 0x10009ede4 0x10009ec9c 0x10006c5a0 0x1882f32b8 0x10006c358 0x187d5d2f4 0x187d4644c 0x187d5cc90 0x187d1c724 0x187d567b8 0x187d55e58 0x187d29660 0x187fc7d6c 0x187d27bc8 0x18355e324 0x18355d5c8 0x18355b678 0x183489664 0x18c5cb5a4 0x187d8e984 0x100139854 0x1941f2a08)
libc++abi.dylib: terminating with uncaught exception of type NSException
In your menu bar go to: Debug -> BreakPoints -> Create Exception BreakPoints. And that should do it. So the next time you run the code, it will stop at the line that caused the exception. And then to the left, you should see the stack trace.

How can I find out the name of an array causing a crash by address on iOS?

So I keep getting this crash and break in my code, but I can't figure out exactly where it's coming from. Xcode doesn't break on the line that is relevant to this, and I looked through all of the thread stacks and none of them show the break. Here is what I am getting:
*** Terminating app due to uncaught exception 'NSGenericException', reason: '***
Collection <CALayerArray: 0x17746b10> was mutated while being enumerated.'
My question is, how so I find out where this array is? Is there some way to look it up in the Xcode console by address to point me to what exactly is happening here? I can't find where I would be mutating some array just by eyeballing my code.
Add exception breakpoint and check the location for crash.
1) Go to the breakpoint navigator.
2) At the bottom left corner click on the ADD
3) Now select "Add Exception Bearkpoint" in that.
4) Make sure "Exception Breakpoint" is enabled.
5) Right click on breakpoint and Change the exception type to Objective-C.
Now run you app and debug the crash area.

Ios Add objects in a NSMutableArray [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
how can I add an object in an array by clicking a button
I use this methode :
- (void)insertNewObject:(id)sender
{
[orderListe addObject:[[DataOrder alloc]initWithName:#"Michael" price:18 taille:#"junior" supplement:#"boeuf"]];
}
When I do that my application crash and say :
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[DataOrder initWithName:]: unrecognized selector sent to instance 0x8aa4fa0'
What can i do to simply add an object to an array ?
Thank you
The error your getting has to do with the DataOrder object. During it's initialization it ran into an error. You're sending it some value it isn't expecting.
Perhaps try and separate the line where you alloc the Data Order object and try to add it to the array?
DataOrder *do = [[DataOrder alloc] initWithName....];
[orderListe addObject: do];
this will let you see where you messed up?
Of course that you can add an object to an array. The exception is thrown because the method initWithName:price: ... is not implemented in the DataOrder class.

Parse Quickstart error [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I'm new to Objective-C and to programming to be honest. Working on a bit of a project and have had the following returned when I try and use the Parse quickstart. Any suggestions?
2013-08-21 21:47:41.388 ParseStarterProject[3284:c07] * Terminating
app due to uncaught exception 'NSInvalidArgumentException', reason:
'cannot setReadAccess for unsaved user'
* First throw call stack: (0x21f4012 0x1d27e7e 0x21f3deb 0x35057 0x3555d 0xaa33 0x32a5 0x2f76 0x3332 0xac5c 0x2e00 0xf761c7 0xf76232
0xec53d5 0xec5cc1 0x2636 0xe92157 0xe92747 0xe9394b 0xea4cb5 0xea5beb
0xe97698 0x214fdf9 0x214fad0 0x2169bf5 0x2169962 0x219abb6 0x2199f44
0x2199e1b 0xe9317a 0xe94ffc 0x2495 0x2395) libc++abi.dylib: terminate
called throwing an exception (lldb)
The Parse SDK is throwing an exception. From the error message, it looks like the problem is that you're sending -setReadAccess for an unsaved user. That makes sense -- it'd probably be difficult to read from an user object that hasn't yet been saved.

Debugging uncaught exception in Xcode

I'm trying to get better at using Xcode. I have the AllExceptions break point turned on. When my app crashes, I see this:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(0xbb8052 0x209cd0a 0xba4db8 0x2255f2 0xc2439 0x12a5e0f 0x12a6589 0x146bfb1 0x147617c 0x12938e1 0x1290602 0x129b211 0x129b23f 0xc16a6 0x138a4c 0x138852 0x14d0e39 0x14d0143 0x14d13cf 0x14d3a31 0x14d398c 0x14cc3e7 0x1234812 0x1234ba2 0x121b384 0x120eaa9 0x28d3fa9 0xb8c1c5 0xaf1022 0xaef90a 0xaeedb4 0xaeeccb 0x28d2879 0x28d293e 0x120ca9b 0x265c 0x25c5)
terminate called throwing an exception(lldb)
On the LHS, when I look at the different threads, I don't see anything that really makes sense. I see some CFRunLoop stuff, but I don't see any "normal" method names like UITableView delegate/datasource methods or my own methods. I was wondering if there was a more informative stack trace available instead of the hex stuff when my app crashes. I know I can set breakpoints at each place I'm accessing the array I think I have a problem with since I'm basically just trying to have an accordion-like tableview with our specific datasource, but I was wondering if there was a faster way by looking at something useful in Xcode. Thanks!
In Xcode,
go to Breakpoint navigator on the left pane.
Click '+' at the bottom.
Choose 'Add exception Breakpoint...'
Let the default selections there and click 'Done'.
Rerun the app and see if execution stops at the line which causing this exception.
The easiest way to handle the exceptions in XCode during development is to add the exception break points.
You can do that as following.
From left menu select Exceptions navigator
Add the exception break point from bottom left button.
Add break point for all the exceptions
Run the app.
In most of the cases XCode will stop the execution on exception and point at the line that caused the exception.

Resources