App crashing with this error message - I cannot find anything about this after googling it- Can someone help please - iphone

Im not getting any compile time errors nor anything comes up when I run Build & Analyze. But at run time my app crashes when I click a uitextfield.
-[__NSCFType textFieldDidBeginEditing:]: unrecognized selector sent to instance 0x583cb90
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType textFieldDidBeginEditing:]: unrecognized selector sent to instance 0x583cb90'
0 CoreFoundation 0x00fa25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x010f6313 objc_exception_throw + 44
2 CoreFoundation 0x00fa40bb -[NSObject(NSObject)doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x00f13966 ___forwarding___ + 966
4 CoreFoundation 0x00f13522 _CF_forwarding_prep_0 + 50
5 UIKit 0x00394581 -[UIControl(Deprecated) sendAction:toTarget:forEvent:] + 67
6 UIKit 0x00396e62 -[UIControl(Internal) _sendActionsForEventMask:withEvent:] +
7 UIKit 0x0039ce11 -[UITextField willAttachFieldEditor:] + 404
8 UIKit 0x003aecdf -[UIFieldEditor becomeFieldEditorForView:] + 653
9 UIKit 0x0039ef98 -[UITextField _becomeFirstResponder] + 99

Chances are that you are either not properly retaining the object you assign as the delegate of your UITextField (e.g. you don't assign it to an outlet property declared retain in IB), or you are calling release or autorelease on an object that you do not own or that you saved into an ivar.
The object eventually gets disposed of, and later a different object happens to be created at the same memory location. But that object, of course, doesn't implement the UITextFieldDelegate protocol, so when the text field tries to send the delegate messages to it it gives you that error instead. Were an object not to be created at that same memory location, you'd get a crash with EXC_BAD_ACCESS instead.

In Interface Builder (or possibly in code, but more likely IB) you have the "Editing Did Begin" Sent Event linked to a method that doesn't exist in your code; perhaps it was renamed, or maybe you neglected to delete that link after deleting the action.
When editing begins in your textField the app tries to call the method indicated in IB and fails; "unrecognized selector" is saying that it doesn't recognize a method by that name.
Either just delete the link or delete it and replace it with an appropriate link.

Related

How to know where crash for postNotificationName:object:userInfo

Is there some method to know crash reason in Xcode 4.6?
The crash stack is :
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0xd9f2c061
Crashed Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x3a74f5aa objc_msgSend + 10
1 Foundation 0x33157599 -[NSNotificationCenter postNotificationName:object:userInfo:] + 73
2 UIKit 0x347830cd -[UIApplication _handleApplicationSuspend:eventInfo:] + 733
3 UIKit 0x346f91e7 -[UIApplication handleEvent:withNewEvent:] + 2459
4 UIKit 0x346f86cd -[UIApplication sendEvent:] + 73
5 UIKit 0x346f811b _UIApplicationHandleEvent + 6155
6 GraphicsServices 0x363ee5a3 _PurpleEventCallback + 591
When you add an observer to the notification centre you have to remove it when the object is being dealloced/destroyed. Otherwise Notification Centre would send the notification to the destroyed object resulting in crash.
1 - check if you properly handle the removing from notification centre. (typically you do this on dealloc method)
2 - If step 1 doesn't help, profile your application with instruments & zombies. it would point out which object is destroyed but still receiving messages.
Almost certainly an object registered with the notification centre to receive that notification and then failed to deregister before deallocation.
The easiest way to catch the problem would be to enable NSZombies — see e.g. this tutorial. If you run with zombies enabled then objects that should have been deallocated remain in memory but raise an exception if anyone attempts to call them. So you can figure out exactly what type of object the notification centre is attempting to call and therefore which object is probably making the mistake.
Given the name of the origin of the notification — _handleApplicationSuspend:eventInfo: — you might also want to have a quick check of anyone registering for UIApplicationWillResignActiveNotification, UIApplicationDidEnterBackgroundNotification and the others related to application suspension.
Might be an useful information that it appears to crash only on ios7, as my project ran perfectly on ios6.
Maybe userInfo is has nil value....
[[NSNotificationCenter defaultCenter] postNotificationName:SayLoggedInNotification object:wSelf userInfo:#{#"from": wSelf.from}];
# wSelf.form is nil

App crashes during startup with valueForUndefinedKey error

During the app startup, I show a table view. Each row shows a managed object's data in some form. One customer is reporting a crash in the app startup. I looked at his crash log and could track down to a place where I use [NSManagedObject valueForKey:] method inside cellForRowAtIndexPath method. The app crashes with [NSManagedObject valueForUndefinedKey:] exception.
How come just one device in a 1000s of devices could get this issue? Running the same version of iOS and the app, I couldn't imitate it in any of my devices. what could have gone wrong?
Last Exception Backtrace:
0 CoreFoundation 0x3549e88f __exceptionPreprocess + 163
1 libobjc.A.dylib 0x368c5259 objc_exception_throw + 33
2 CoreFoundation 0x3549e5c5 -[NSException init] + 1
3 CoreData 0x329d3b23 -[NSManagedObject valueForUndefinedKey:] + 327
4 Foundation 0x312b59d1 _NSGetUsingKeyValueGetter + 125
5 CoreData 0x3298d995 -[NSManagedObject valueForKey:] + 121
6 MyApp 0x0000c513 -[Activity isOn:] (Activity.m:371)
7 MyApp 0x0000beaf -[Activity firstMarkableDate] (Activity.m:163)
8 MyApp 0x0000c0cb -[Activity statusString] (Activity.m:220)
9 MyApp 0x0000bd51 -[Activity statusColor] (Activity.m:139)
10 MyApp 0x00004af1 -[ActivityListViewController tableView:cellForRowAtIndexPath:] (ActivityListViewController.m:418)
11 UIKit 0x3251d0a3 -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:] + 547
This may be a memory management issue. See -[Activity isOn:] where it invokes valueForKey:. The object you send valueForKey: is apparently of the wrong class. See where the object is coming from.
The object may get over-released and its memory address may get occupied by an object of a different class which isn't KVO-compliant for trackname key. If that's the case, I would bet that your app gets EXC_BAD_ACCESS even more often.
Why would that happen? NSManagedObjects have many subtleties with regard to their lifetime. They may get deleted in other parts of your app, for example, so you should always expect that and act appropriately.
I hope this will point you in the right direction.

How to read Xcode console output?

As a Java and PHP developer new to Xcode, I am having trouble dealing with memory errors. I have a sample program from a book, which crashes on startup with "Program received signal 'SIGABRT'." I don't know what to do with the console output below. I realize it's some kind of stack trace, but the name on the left is just the name of the application, not a class or file. I don't know what "main + 121" or "start + 53" means or where to look. Any guidance would be appreciated.
2011-05-11 10:43:23.071 FlowerInfoNavigator[22537:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFDictionary objectForKey:]: method sent to an uninitialized mutable dictionary object'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f16313 objc_exception_throw + 44
2 CoreFoundation 0x00dbf542 -[__NSPlaceholderDictionary objectForKey:] + 194
3 FlowerInfoNavigator 0x0000289a -[RootViewController tableView:didSelectRowAtIndexPath:] + 330
4 UIKit 0x0008bb68 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
5 UIKit 0x00081b05 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
6 Foundation 0x0079b79e __NSFireDelayedPerform + 441
7 CoreFoundation 0x00da38c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
8 CoreFoundation 0x00da4e74 __CFRunLoopDoTimer + 1220
9 CoreFoundation 0x00d012c9 __CFRunLoopRun + 1817
10 CoreFoundation 0x00d00840 CFRunLoopRunSpecific + 208
11 CoreFoundation 0x00d00761 CFRunLoopRunInMode + 97
12 GraphicsServices 0x00ffa1c4 GSEventRunModal + 217
13 GraphicsServices 0x00ffa289 GSEventRun + 115
14 UIKit 0x00022c93 UIApplicationMain + 1160
15 FlowerInfoNavigator 0x00001b99 main + 121
16 FlowerInfoNavigator 0x00001b15 start + 53
)
terminate called after throwing an instance of 'NSException'
(gdb)
On the right are the methods that were called that are on the stack. I generally just look for anything that is from one of my methods (though this won't always work) and then it'll give you the method call that the problem originated from. in the trace at call number 3 on "FlowerInfoNavigator" the method tableView:didSelectRowAtIndexPath: was called and somewhere in there is what caused the crash. You should be able to use the debugger and breakpoints to narrow it down from there hopefully. Good luck.
Edit: as I relooked at your error message: at the top of it it gives you the error. You tried to retrieve an object from a NSDictionary that wasn't initialized yet, and from above, it occurred in your didSelectRowAtIndexPath method
The console wouldn't be the only place you look. Take a look at your Debugger too. Over there there is usually one line that is bolded. If you tap that it'll show you exactly where the crash happened.
Looks like you didn't init your NSDictionary
The Crash is due to nsdictionary is not initialized yet and how to search for during a crash ,first look at console so you will get idea about what caused the crash or exception and to get where the application crashed you can check out debugger .In the debugger the the particlar line will be in bold where the application crashed.
Apart from you can also use NSZombieEnabled (BOOL) to get what is causing the application crash .More about NSZombieEnabled can be found here http://developer.apple.com/library/ios/#documentation/Xcode/Conceptual/iphone_development/130-Debugging_Applications/debugging_applications.html
Note : here do make sure to make NSZombieEnabled set to NO at time of processing the application to submission to apple store.
Hope this helps.

Unrecognized selector on calling Google Toolbox for Mac NSString category method in iOS

I'm building a static library for use in an iOS project, and I want to decode XML entities returned from a web service. I've grabbed Google Toolbox for Mac and added the following files to my project:
GTMDefines.h
GTMNSString+HTML.h
GTMNSString+HTML.m
Then in my own .m file I'm doing this:
#import "GTMNSString+HTML.h"
// then in one of my methods:
NSString *value = [anotherNSStringValue gtm_stringByUnescapingFromHTML];
The code compiles fine, but when I run the app that uses my static library it crashes with a NSInvalidArgumentException, complaining that the gtm_stringByUnescapingFromHTML selector isn't recognised for NSString:
2011-02-10 12:21:38.401 MyApp[20356:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString gtm_stringByUnescapingFromHTML]: unrecognized selector sent to instance 0x71403e0'
*** Call stack at first throw:
(
0 CoreFoundation 0x0111bbe9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x012705c2 objc_exception_throw + 47
2 CoreFoundation 0x0111d6fb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x0108d366 ___forwarding___ + 966
4 CoreFoundation 0x0108cf22 _CF_forwarding_prep_0 + 50
5 MyApp 0x00028dcf -[GSMyAppXMLParser parseData:] + 714
// Rest of stack trace removed
)
terminate called after throwing an instance of 'NSException'
I've found a few similar issues on Stack Overflow, and in each case the questioner has subsequently commented that they fixed it by tweaking a linker setting - but without disclosing which setting! If anyone can help me with this I'd be forever grateful!
I’m guessing that would be the -ObjC and -all_load flags.
You add these to the ‘Other Linker Flags’ of the app that links agains the library, not the library itself.
For more info see: http://developer.apple.com/library/mac/#qa/qa2006/qa1490.html

this class is not key value coding-compliant for the key authView [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.
When i run my app on simulator it runs well, when i try with device doesn't work and i get these errors:
NOTE: i didn't find any kind of class authView in my code
2011-02-24 12:04:14.472 TestP[473:307] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<TestP 0x19d2b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key authView.'
*** Call stack at first throw:
(
0 CoreFoundation 0x33ac0987 __exceptionPreprocess + 114
1 libobjc.A.dylib 0x3347b49d objc_exception_throw + 24
2 CoreFoundation 0x33ac0705 -[NSException dealloc] + 0
3 Foundation 0x3367db4f -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 182
4 Foundation 0x3367d03b _NSSetUsingKeyValueSetter + 90
5 Foundation 0x3367eda3 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 194
6 Foundation 0x33630b17 -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 130
7 UIKit 0x3224c60f -[UIRuntimeOutletConnection connect] + 66
8 CoreFoundation 0x33a63fc7 -[NSObject(NSObject) performSelector:] + 18
9 CoreFoundation 0x33a6cd51 -[NSArray makeObjectsPerformSelector:] + 388
10 UIKit 0x3224b577 -[UINib instantiateWithOwner:options:] + 586
11 UIKit 0x3224cb39 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 92
12 UIKit 0x3209e871 -[UIApplication _loadMainNibFile] + 96
13 UIKit 0x3209a1fd -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 180
14 UIKit 0x3206648b -[UIApplication handleEvent:withNewEvent:] + 1114
15 UIKit 0x32065ec9 -[UIApplication sendEvent:] + 44
16 UIKit 0x32065907 _UIApplicationHandleEvent + 5090
17 GraphicsServices 0x33b0ef03 PurpleEventCallback + 666
18 CoreFoundation 0x33a556ff __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
19 CoreFoundation 0x33a556c3 __CFRunLoopDoSource1 + 166
20 CoreFoundation 0x33a47f7d __CFRunLoopRun + 520
21 CoreFoundation 0x33a47c87 CFRunLoopRunSpecific + 230
22 CoreFoundation 0x33a47b8f CFRunLoopRunInMode + 58
23 UIKit 0x32099309 -[UIApplication _run] + 380
24 UIKit 0x32096e93 UIApplicationMain + 670
25 TestP 0x00002213 main + 98
26 TestP 0x000021ac start + 40
)
terminate called after throwing an instance of 'NSException'
You've probably got your File's Owner stuff messed up in your xibs. This exception is getting thrown during nib unarchiving (as evidenced by +[UINib...] in the backtrace). It's attempting to hook up your IBOutlets that you defined.
One of your views is set up to be the authView of the the File's Owner. However, when it's time to unarchive the nib, the owner doesn't have an authView property, so the unarchiving is failing.
#Dave DeLong pointed out right.
Workaround
Find when the exception thrown, which viewController is being loaded.
Then check the nib file of the viewController, there must be an IBOutlet attached in xib but might be missed in the viewController.h file or might be some control which was attached is missing in xib file.
Why running in Simulator? Sometimes it ends in messing up.
Just do the steps
Build -> Clean
Build -> Clean All Targets
Now it runs the real code, may be issue got resolve on device also or may be it start throwing exception on simulator also in case if there is really an issue. (I already have mentioned workaround)
This is how I solved this problem. I went into my 'Story Board' file and selected the view that was causing the problems. I then clicked on the Connections Inspector tab and you will see connection(s) with exclamation points to the right instead of solid circles. Remove these and make adjustments if necessary. Save>Run your app and should work. Hope this helps :)
I think that one possible cause for raising that exception is when you have changed the name of some IBOutlet variable after the storyboard connections are already done. Thus the UI element in the storyboard is still referencing to the old variable name. I solved this for me by checking the XML representation of the storyboard (Right click on your .storyboard file and open it as Source Code) and deleting the old (unneeded) IBOutlet variable name.
For example let say you have one UITextField on the storyboard and have the corresponding property for it:
#property (retain, nonatomic) IBOutlet UItextField *myTextField;
You connect the UI element in the storyboard to that property and then you decide to rename somehow the variable. Now if you right click on your UITextField in the storyboard, you will notice that there exists two referencing outlets - the old one and the new one. You can delete the old one by clicking 'x' sign in the Connections Inspector or by editing the XML variant of the storyboard file.
something went wrong when in xcode 4 with some reference , cause i declared IBOutlet that reference authView then run and it worked!, then i removed the IBOutlet declaration and worked well
I just cleaned the project and deleted the app from the device and it worked again. Error was referencing a view that i had already removed.
You have probably created an IBOutlet, then deleted it, then linked a new one, but in the xib 'Inspector' you forgot to delete the link and now have a duplicate IBOutlet ref that the compiler cannot find.
i have found these errors arise mostly when you connect properties, edit them, and connect them again.. analyse your connection inspector for unexpected values, that remain from your previously created and destroyed connection.
In my case it was even more spooky. I had a XIB associated to the VC that I had removed completely as went for code-only. Run on Simulator nicely but would crash on Device systematically.
So I clean, rebuild, closed XCode, went for a snack and shout at the mac. Nothing, the compiler kept pointing to an inexistent button on an inexistent XIB.
Tried by changing the name of the class and that worked!
It seems that your Interface Builder did not work properly.
As suggested before, try by cleaning and rebuild. If it doesn´t work, I´d suggest you to re-create your xib interface. It worked for me in a similar occasion.