iOS9 Storyboard "Setting empty vector for variable" exception - Terminating app due to uncaught exception 'NSInternalInconsistencyException' - objective-c

I'm running into an issue where my main storyboard got corrupted after I messed around with it, and I get the following cryptic error message. The app catches error in main() and is followed by SIGABRT with the following exception:
Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '{objective 0x147dc56e0: <1:-25.3333> + <1:1>*0x147dc39b0.posErrorMarker{id: 91} +
<1:0.125>*0x147dc50e0.negError{id: 90} +
<1:-0.125>*0x147e2e300.marker{id: 77} +
<1:0.125>*0x147e2e300.slack{id: 78} +
<1:0.125>*0x147e2e350.marker{id: 81} +
<1:-1>*0x147e2e440.marker{id: 87} +
<1:-0.125>*0x147e436b0.marker{id: 63} +
<1:0.125>*0x147e437f0.marker{id: 72} +
<1:-0.125>*0x147e764c0.marker{id: 55} +
<1:0.125>*0x147e88820.marker{id: 52}}:
internal error. Setting empty vector for variable 0x147dc1b90.negError{id: 48}.'
Setting another storyboard to be the main interface has the app starting up correctly.
How can I find the element that is causing "Setting empty vector for variable" storyboard exception?

In case it helps anyone else, I was getting an Setting empty vector for variable error with use of a UIStackView where the spacing property was not set.
Not sure if it's the actual cause, or just a weird correlation, but setting spacing to a non-zero value prevents this error for me.

try using po 0x147dc1b90 in the debugger console, where 0x147dc1b90 is your variable address, which you can see in the last line, to see more details

For me it was calling self.view.layoutIfNeeded() without main queue was the issue.
DispatchQueue.main.async {
self.view.layoutIfNeeded()
}

Related

[__NSArrayM insertObject:atIndex:]: object cannot be nil - how determine where is the error?

I have big project with async event, and sometimes i have error
[__NSArrayM insertObject:atIndex:]: object cannot be nil,
but I havent idea where is throwing this error.. How can I catch this error? I make assert in everywhere where I make operation insertobject:atIndex and nothing..
This is stack:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
*** First throw call stack:
(0x34c352a3 0x32f4597f 0x34b7f8d9 0xc48db 0xc3ced 0xc3b41 0x1178d9 0x148aed 0x103cfd 0x102fc9 0x101f95 0x35f25595 0x35f7a13b 0x35f7a081 0x35f79f65 0x35f79e89 0x35f795c9 0x35f794b1 0x35f67b93 0x35f67833 0xd820b 0x35fc8275 0x3604aea9 0x326efa6f 0x34c0a5df 0x34c0a291 0x34c08f01 0x34b7bebd 0x34b7bd49 0x350b82eb 0x35f5a301 0x62e45 0x62de0)
libc++abi.dylib: terminate called throwing an exception
A good way to check where your code is crashing is:
1) goTo the breakpoint tab in Xcode.
2) click on the '+" button at the bottom.
3) Add Exception Breakpoint
a) In the break tab select both:
i) on Throw
ii) on Catch
and build and r
un.
4) These breakpoints will give you exactly where your app is crashing 90% of the times.
Hope this helps you in someway. :)
Sometimes if you can not find the exception where its throwing. Just try adding these symbolic breakpoints in your project. Then run
objc_exception_throw
malloc_error_break
[NSException raise]
In your Xcode goto Product -> Debug -> Create Symbolic Breakpoint. Enter each breakpoint mentioned above in Symbol then press Done or you can alternatively create by going to the Breakpoint navigator (cmd + 6) in bottom left corner you can find + symbol, click that + then Add symbolic breakpoint . Now try to run, it'll get you to the specific line where its crashing.
Think you need to handle the null value from Array .
Its working for me
something like:
if ( array ! = nil ) {
NSLog(#"name is nil");
} else {
// addobject to array
}
Apparently, the object you inserted should not be nil. Check it!

Find the empty array

Is there some method to understand what of my 20 Arrays is empty when I get this problem?
2012-12-06 16:52:05.409 Posizione Corrente 3[3738:907] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x383042a3 0x34adb97f 0x3824fb75 0x560ab 0x38a49545 0x38a2e30b 0x38a457c7 0x38a01803 0x3bed7d63 0x3bed7901 0x3bed8835 0x3bed821b 0x3bed8029 0x3bed7e89 0x382d96cd 0x382d79c1 0x382d7d17 0x3824aebd 0x3824ad49 0x340232eb 0x38a522f9 0x7c675 0x3940bb20)
libc++abi.dylib: terminate called throwing an exception
(lldb)
If you set a breakpoint on Objective-C exceptions using Xcode's Breakpoint Navigator, the program should stop when it encounters that error and show you the code that caused it. From the line of code, it should be reasonably easy to see which array is implicated.
You can check with the following code, if you array contains any value or not.
if([myArray count]==0){
//do this
}
else{
//do you array manipulation
}

app crashes when [self setValue:forKey:] is called

.h File
...
#property(nonatomic,readwrite)NSNumber *isConnectionWithServerEstablished;
when ever i setValue for isConnectionWithServerEstablished the app crashes
CRASH POINT:
[self setValue:Number forKey:#"isConnectionWithServerEstablished"];
OUTPUT LOG
2012-07-24 16:08:26.517 Protocol[1337:11103] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '<__NSMallocBlock__: 0x6b84a70>: An -observeValueForKeyPath:ofObject:change:context: message was received but not handled.
Key path: isConnectionWithServerEstablished
Observed object: <LobbyProtocolModel: 0x6b850b0>
Change: {
kind = 1;
new = 1;
}
Context: 0x0'
*** First throw call stack:
(0x155e022 0x1b16cd6 0x1506a48 0x15069b9 0xe540ef 0xdc0d91 0xdc0895 0xda633e 0xdc8a82 0xdbcf30 0xdbcedb 0xb606 0xdc0d91 0xdc0895 0xda633e 0xdc16ab 0xe00f19 0xdbcfbf 0xdbcedb 0x5716 0x4d1e 0xe5fa29 0x1529855 0x1529778 0xda419a 0xd5e4 0x24661 0x216d330 0x216ef0c 0x216ecb4 0x216e402 0x9722cb24 0x9722e6fe)
terminate called throwing an exception(lldb)
Something is observing your object, but that object isn't implementing -observeValueForKeyPath:ofObject:change:context:. Your observer needs to implement that method if you're doing manual observing.

Thread 1 received signal Sigbart?

Hi i am new to Xcode and I'm making a simple addition app
I just completed it when i got this:
2012-07-17 19:06:55.478 Add[3526:fe03] * Terminating app due to
uncaught exception 'NSUnknownKeyException', reason:
'[ setValue:forUndefinedKey:]: this
class is not key value coding-compliant for the key Result.'
* First throw call stack: (0x13c7022 0x1558cd6 0x13c6ee1 0x9bf022 0x930f6b 0x930edb 0x94bd50 0x23371a 0x13c8dea 0x13327f1 0x23226e
0xd81fc 0xd8779 0xd899b 0x37401 0x37670 0x37836 0x3e72a 0xf596 0x10274
0x1f183 0x1fc38 0x13634 0x12b1ef5 0x139b195 0x12ffff2 0x12fe8da
0x12fdd84 0x12fdc9b 0xfc65 0x11626 0x1b7d 0x1ae5 0x1) terminate called
throwing an exception(lldb)
it automatically took me here to main.m which i will provide the code for:
//
// main.m
// Add
//
// Created by Dominic Kynkor on 7/17/12.
// Copyright (c) 2012 academy of the holy names. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "AdditionAppDelegate.h"
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AdditionAppDelegate class]));
}
}
Does anyone know whats going wrong?
This isn't necessarily where the error occurred, but it is just showing the app entry point where the uncaught exception has fallen back to. It looks as though somewhere else in your code you might be trying to use an NSDictionary incorrectly. The best thing to do is to set a breakpoint where you are calling the setValue method and single-step through the code until it throws the exception.
I'm not 100% sure of it. But this error normally appears when you have mis-connections in XIB files. Check your XIB file, ctrl-click the File's Owner, see if any warning there.
What you want the debugger to do is catch the exception at the point it happened, so you can look at the stack trace and see where the setting of Result is happening.
To enable exception breakpoints in Xcode, go to the Breakpoints tab and click the plus sign at the bottom, choose to add an Exception Breakpoint. Take the defaults on the resulting dialog and click Done.
Now your debug session will be far more productive!

about removeObjectAtIndex

appdata.items is NSMutableArray object.
source code
-(void)deleteAppDataItemId:(NSInteger)identifier{
NSLog(#"%#", [appdata.items objectAtIndex:identifier]);
NSLog(#"%i", identifier);
[appdata.items removeObjectAtIndex:identifier];
}
log
2009-11-08 21:53:01.683 xxx[14283:207] (
200,
"",
2009-11-08 21:52:53 +0900
)
2009-11-08 21:53:01.684 xxx[14283:207] 0
2009-11-08 21:53:01.685 xxx[14283:207] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSCFArray objectAtIndex:]: index (0) beyond bounds (0)'
What caused this error?
Set the debugger to break on objc_exception_throw, then run your program in the debugger. When you hit the exception, look at the stack trace. Some of the frames in the stack will be in Cocoa or CF code; others will be in your code. Switch to the topmost frame that's in your code, and start examining variables. You should find the problem in short order that way.
I believe the crash happens in another array. Have you tried using a debugger?