Finding a bug using Xcode - attempt to insert nil value - iphone

I am getting a random bug in my app, which is causing it to crash. The problem I am facing is XCode doesn't tell me where the crash is happening only the below information. Can someone tell me how I can find out where I might be able to find the problem within the code? It must be crashing at the same point as when the app does crash it always shows the below.
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary
setObject:forKey:]: attempt to insert nil value (key: 0)'
* First throw call stack: (0x381e48bf 0x37d301e5 0x381e47b9 0x381e47db 0x381516bb 0x9237b 0x91121 0x8f0c5 0x8abc1 0x37b9d 0x8b68f
0x3550850f 0x381b0577 0x3813c0cf 0x3547c3fb 0x3547dc2b 0x8d005
0x3814322b 0x34495 0x32e31 0x3372d 0x30a59 0x3813e435 0x7b1df 0x7b88d
0x79e25 0x31ca650f 0x31ca5f01 0x31c8c4ed 0x31c8bd2d 0x37f12df3
0x381b8553 0x381b84f5 0x381b7343 0x3813a4dd 0x3813a3a5 0x37f11fcd
0x31cba743 0x89e8b 0x24a4) terminate called throwing an
exception(lldb)

Have you turned on exception breakpoints? Click the + at the bottom left of the Breakpoint Navigator, then select Add Exception Breakpont.
You can right click the breakpoint to edit it…
This will cause the code to stop at the point where the error occurs.

There is a solution that I usually use on my projects, setting up some special breakpoint.
To do that:
Open XCode
Goes to "View -> Navigators -> Show Breakpoint Navigators"
Now add some new breakpoints clicking the "+" button:
Add exception breakpoint
Add Symbolic breakpoint with symbol [NSException raise]
Add Symbolic breakpoint with symbol objc_exception_throw
Run again your project, application will stop on the line that is causing your problems.

error is evident enough. in any of your line, where you are setting some object for dictionary, you key is nill, which is not allowed

your problem is that you are using setObject: forKey Method to NSDictionary just make it NSMutableDictionary then try this method you can't assign value for NSDictionary like you are trying it's only for NSMutableDictionary.
i hope you will get my point what i am try to say.

Try this:
if([myDictionary objectForKey:#"string"]!= nil && [myDictionary objectForKey:#"string"]!= Nil) { }

Related

iOS - Video playing gives errors

When I follow this tutorial, it gives me an error on the [playercontroller release]; line, so I remove it, and then it gives me these errors when I try to run it.
I tried making another app to test the video, and it works seamlessly, but it will not work in my main app. Can anyone help?
And when I reimported the framework, and tried to play the video, it gives me this error:
2012-08-17 11:27:03.174 LYWAM Tour[768:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initFileURLWithPath:]: nil string parameter'
*** First throw call stack:
(0x1e15022 0x10fdcd6 0x1dbda48 0x1dbd9b9 0xba253b 0xba24c5 0x54ac 0x1e16e99 0x26314e 0x2630e6 0x309ade 0x309fa7 0x308d8a 0x2882cf 0x2885e6 0x26edc4 0x262634 0x16f7ef5 0x1de9195 0x1d4dff2 0x1d4c8da 0x1d4bd84 0x1d4bc9b 0x16f67d8 0x16f688a 0x260626 0x24cd 0x2435 0x1)
terminate called throwing an exception(lldb)
I take it GVE1ViewController is a class you wrote yourself? Does it definitely implement a method called GrommeVideoExcerpt1? Is what you assigned to the variable actually an instance of GVE1ViewController (or a subclass?) Put in an NSLog to check that it really is an instance of GVE1ViewController.
To do the NSLog, you need a line of the form:
NSLog(#" My controller = %#", myVar);
where myVar is whatever variable you have containing a reference to the GVE1ViewController.

Thread 1: signal SIGABRT xcode 4.4 ios 5.1 objective-c HELP >.<

Ok so yesterday I had some trouble with this error, turned out I just needed to be patient and read through more of the book. This time I have got to the end of the project and I am getting this error at a different point.
I have isolated the line of code causing the issue but I'm not sure what the issue is!
htmlString=[htmlString stringByAppendingString: appDelegate.savedNumber];
Debug console is saying:
2012-08-09 13:06:47.235 tester[1357:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSCFConstantString stringByAppendingString:]: nil argument'
*** First throw call stack:
(0x14b3022 0xeb3cd6 0x145ba48 0x145b9b9 0x941b92 0x29bd 0xdda1e 0x3c401 0x3c670 0x3c836 0x4372a 0x24c2 0x14386 0x15274 0x24183 0x24c38 0x18634 0x139def5 0x1487195 0x13ebff2 0x13ea8da 0x13e9d84 0x13e9c9b 0x14c65 0x16626 0x20e2 0x2055)
terminate called throwing an exception
Anyone have any ideas? :)
It is because appDelegate.savedNumber is nil (does not set) . And why it is nil this is another question.
Looks like exactly what's written, you're passing nil argument to the method. Check if your savedNumber is a valid string object.

How to use RegexKitLite in Xcode 4.3.1?

I'm having trouble to use RegexKitLite to match string like
NSString *encodedPoints=[apiResponse stringByMatching: #"\\\"([^\\\"]*)\\\"^[^:]*"
capture: 0];
and apiResponse is:
#"http://maps.google.com/maps?output=dragdir&saddr=20.001364,73.749283&daddr=19.991499,73.744095"
So, to do by this way i am getting following error:
__NSCFString stringByMatching:capture:]: unrecognized selector sent to instance 0x131fc0
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString
stringByMatching:capture:]: unrecognized selector sent to instance
0x131fc0'
* First throw call stack: (0x3422b8bf 0x3447b1e5 0x3422eacb 0x3422d945 0x34188680 0xb97b 0xad2f 0xaa2d 0xa617 0x34185435
0x375ef9eb 0x376b53cf 0x34185435 0x375ef9eb 0x375ef9a7 0x375ef985
0x375ef6f5 0x375f002d 0x375ee50f 0x375edf01 0x375d44ed 0x375d3d2d
0x30a06df3 0x341ff553 0x341ff4f5 0x341fe343 0x341814dd 0x341813a5
0x30a05fcd 0x37602743 0x4571 0x2838)
I have trying to find solution with googling but not getting exact solution.
Please help...
Ensure you have the correct library included into your project.
Go to your Project Navigator and selet the project.
Click on the Target and select the Build Phases tab, and open the Link Binary With Libraries.
Press the + Button, and search for libicucore.A.dylib. Add this library to your project.
Next, you will need to add the compile source, which is in Compile Sources just above Link Binary With Libraries. Once again, hit the + button and add RegexKitLite.m to the target. If you attempt to build the project at this state, you should get a lot of errors in the RegexKitLite.m file. To correct this, add the following compiler flag to the file by double clicking the RegexKitLite.m file in the Compile Sources area and then including -fno-objc-arc into the pop-up that appears. Hit done, and you will have hopefully added the library source to your project.
Just as a note, -fno-objc-arc removes the Automatic Reference Counting while compiling that source file. The errors the file gets without that compiler flag have to do with ARC, so it solves the problem.
This solved my issues when working with RegexKitLite, so hopefully it will for you.

this class is not key value coding-compliant for the key view [duplicate]

This question already has answers here:
Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
(79 answers)
Closed 7 years ago.
i´m very new to xcode... a made an app (simple calculator) work´s pretty good (on simulator and device).
When i set the main interface in the summary options from Target, i get the following error when starting the simulator:
2012-04-14 12:17:27.123 CalcTest[27550:f803] * Terminating app due
to uncaught exception 'NSUnknownKeyException',
reason:
'[<UIApplication 0x6a14650> setValue:forUndefinedKey:]: this class is
not key value coding-compliant for the key calculatorScreen.'
* First throw call stack: (0x12db022 0x18f8cd6 0x12daee1 0xcc2022 0xc33f6b 0xc33edb 0xc4ed50 0x53671a 0x12dcdea 0x12467f1 0x53526e
0x536eb7 0x313ce1 0x313ff8 0x31317f 0x322183 0x322c38 0x316634
0x27fcef5 0x12af195 0x1213ff2 0x12128da 0x1211d84 0x1211c9b 0x312c65
0x314626 0x1bad 0x1b15 0x1) terminate called throwing an
exception(lldb)
to find the problem, i started a new view based project.
Run the empty new project on the simulator -->works,
But when I set the main interface, to ViewController, in the summary -->the Simulator crash with
2012-04-14 12:11:17.492 crash[27494:f803] * Terminating app due to uncaught
exception 'NSUnknownKeyException', reason:
'[<UIApplication 0x6a6f4b0> setValue:forUndefinedKey:]: this class is
not key value coding-compliant for the key view.'
* First throw call stack:
(0x13c7022 0x1558cd6 0x13c6ee1 0x9bf022 0x930f6b 0x930edb 0x94bd50
0x23371a 0x13c8dea 0x13327f1 0x23226e 0x233eb7 0x10ce1 0x10ff8 0x1017f
0x1f183 0x1fc38 0x13634 0x12b1ef5 0x139b195 0x12ffff2 0x12fe8da
0x12fdd84 0x12fdc9b 0xfc65 0x11626 0x1d4d 0x1cb5) terminate called
throwing an exception
is there a solution for the problem?
If you have a control in your nib (xib file) that is linked to a property (IBOutlet) or method (IBAction) in your view controller, and you have either deleted or renamed the property or method, the runtime can't find it because it has been renamed and therefore crashes.
In your case, you have set the Main Interface property of the project to your ViewController.nib. This is a problem because the only nibs that should be used as Main Interface should have UIWindows in them and the File Owner in that nib should be set to the AppDelegate. The UIWindow in the nib should be linked to the File Owner's (AppDelegate) window property. Because you set that with a nib without the traits the runtime was looking for, it gives you this error.
The solution is to leave the Main Interface blank as you do not have to set up UIWindows manually anymore.
Just had the same problem and fixed it by right Control-Clicking controls in the xib file to see referencing Outlets. Turned-out that some of the control were still referencing and older name and causing this error to happen.
if you get a message similar to:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key
click the add (+) at the left bottom corner of the BreakPoint navigation area, choose 'add Exception Breakpoint', since it is crashing because of 'NSUnknownKeyException', and opt for 'All'. Run the program. The program stops at the first exception.
try this, select File's Owner then click on the "Connection Inspector" (upper on the top of right pane), you will see all the outlets. Look for any sign like this (!) you will find it on the small circle which indicates a missing outlet, all you have to do is linking it properly or remove the outlet.
Try this,
Go to Target=>Build Phases=>Compile Sources
Then include 'calculatorScreen.m'
I was facing the same problem. In my case i had renamed the text label in .h file. So there was multiple reference for that label in my main.storyboard file. Once i removed old reference my code started working.
Please check your target membership
select first option.this may help to others

Need help fast -- CoreData error

need help desperately ahead of a demo in a few hours... App was working on my test device fine last night. Added some data (as I always do) this morning and now I get this error during a save operation:
Serious application error. Exception was caught during Core Data change processing:
*** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
(key: _ContentChange_OldIndexPathKey) with userInfo (null)
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: '*** -[NSCFDictionary setObject:forKey:]: attempt to insert nil value
(key: _ContentChange_OldIndexPathKey)'
The funny thing is that if I download my sqlite file to my Mac and feed it into the simulator, everything works just fine. The crash only occurs on the test device.
Any ideas?
I too was encountering this error. Nullifying the NSFetchedResultsController delegate does stop it from crashing, but is not a fix. The problem seems to be specifying a sort key in the NSFetchRequest which is null for some objects. Some sort call made in NSFetchedResultsController expects none null values.
This is an old post but I will give my comment anyway :)
I have experienced similar problem and deleting the cache for the NSFethedReultController solved the problem.
[NSFetchedResultsController deleteCacheWithName:<cacheName>];