add categories in xcode4 - objective-c

I copied the timeAgo category for NSDate in XCODE4, but i get the following runtime error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDate timeAgo]: unrecognized selector sent to instance 0x17e000'
I read in other posts i need to add a linking flag, which I did as follows:
But its still not working. What am I missing to use third party categories?

I don't think you ought to mess with the linkers, at least not there. Wherever you got that category from may have mentioned that the file you put that in needs to be compiled, which you check by going to your project settings -> Build Phases -> Compile Sources. Make sure the category's .m file is in there.

Related

Crash in the execution of a queue glmtl.telemetry

Exactly 60 seconds after launching my app it crashes with an uncaught exception:
libc++abi.dynlib: terminating app due to uncaught exception of type NSException
*** Terminating app due to uncaught exception of type 'NSInvalidArgumentException', reason: '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: BundleVersion)'
The crashing thread has a random number (it is #7 in the attached screenshot) and it is always created for an unknown to me queue glmtl.telemetry.
The crash occurs only on one device (iPhone 11 Pro Max) and iOS 14.0 (it was then replicated with iOS 14.0.1).
I am not using in the project anywhere a key "BundleVersion". (There is CFBundleVersion in the info.plist, but does not seem to be related).
Can this be caused by the project sources?
This is not an explanation of the issue but the crash stopped appearing after adding a group of missing resource files to a folder (not a group but a folder) in the bundle.
Fix
I am having the same issue. In my case, I needed to add CFBundleVersion to the project's Info.plist since the exception mentions the "BundleVersion" key and because I recalled seeing XCode complain about invalid bundles when that key is missing.
My guess is that those recommended CFBundle* keys should be set for the main project's Info.plist and any embedded framework or projects with their own Info.plist. I'm just surprised XCode 12 doesn't raise that error right now at build time.
Source of the issue (?)
Do you use OpenGL in your app? I could not find what glmtl is, but it seems that the crash occurs exactly 1 minute after I instantiate a new OpenGL context. The crash will still occur after 1 minute if I delete the context before that, but it will be delayed another minute if I create a new instance in between.

unrecognized selector sent to instance (_setViewDelegateContentOverlayInsetsAreClean)

It looks like there is a lot of way to get this error. I couldn't find any solution that worked in my case. The difference with most thread with the same error, is that the view that throw the error is my initial view and not called by a segue.
Here Is my error log:
Tabuleo[87837:3767493] -[loginViewController _setViewDelegateContentOverlayInsetsAreClean:]:
unrecognized selector sent to instance 0x7fb513d104e0
2018-07-03 13:37:25.365645+0200 Tabuleo[87837:3767493]
*** Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[loginViewController _setViewDelegateContentOverlayInsetsAreClean:]:
unrecognized selector sent to instance
I can't figure out by myself where it comes from because in my code I don't have any method called "_setViewDelegateContentOverlayInsetsAreClean".
At this point I don't have any clue and I read almost all post related to that.
My code is about 350 lines so I put a link to download it if it helps.
loginViewController.m
Thanks for your help.
I figured it out finally.
I don't know exactly where it was messed up but redo every link of my elements in my storyboard for this view finally ended up working !
So if that happen just redo your links from storyboard to .h file.

How to use Xcode output to determine source of crash?

I have the following output from my app at the moment:
2012-09-14 11:55:32.558 projectname[2172:707] -[__NSCFBoolean isEqualToString:]:
unrecognized selector sent to instance 0x3ec4ba18
2012-09-14 11:55:32.570 projectname[2172:707] *** Terminating app due to uncaught
exception 'NSInvalidArgumentException', reason: '-[__NSCFBoolean isEqualToString:]:
unrecognized selector sent to instance 0x3ec4ba18'
*** First throw call stack:
(0x3263788f 0x3468d259 0x3263aa9b 0x32639915 0x32594650 0x41e47 0x417d3 0x46af7
0x320beefb 0x320bdfd9 0x320bd763 0x32061f15 0x325961fb 0x342faaa5 0x342fa6bd
0x342fe843 0x342fe57f 0x342f64b9 0x3260bb1b 0x32609d57 0x3260a0b1 0x3258d4a5
0x3258d36d 0x316e4439 0x3208ccd5 0x17e77 0x15ca4)
terminate called throwing an exception
I can see that the problem is that I'm trying to compare a BOOL to an NSString, the comparison is on data from a web service and it's always been BOOL before now. That's besides the point in this case anyway.
What information is in that log that can actually help me find the line of code that's causing the problem? I can see which instances (e.g. 0x3ec4ba18) are causing it but the log doesn't even tell me what type they are, let alone a line number.
Add an exception breakpoint by going to the exceptions pane (in the left sidebar), clicking the + and selection "Exception breakpoint". Then when you run the debugger will pause where the exception is actually thrown rather then when it is caught (or rather uncaught) at the top level.
There are many tutorials on this, Raywinderlich has one of good tutorial for determining crash from the console log..
Here you can get them..
My App Crashed, Now What? – Part 1
My App Crashed, Now What? – Part 2
After following these, come to know the specific reason of crash then google for this, you can resolve it easily.

RestKit weird error

I have been up and running with RestKit for ios and I feel it is great. But, I have some serious problem. I am trying to use the objectmapper in a application. While a test application with only a single view controller works fine and is able to load all the data in array. But, I try to integrate into the existing application, it always crashes with error ;
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString objectForKey:]: unrecognized selector sent to instance 0x8b55e90'
I have a core data datamodel but I have not used it for the mapping until. The code in both the test application and the existing app are same. It is annoying that the same code works fine with a single view controller while the same things does not work for integration. Any help would be much appreciated !
"unrecognized selector sent to instance" usually means that you are trying to call a method on an object that is no longer existent in memory. First you need to find out which object this is by enabling zombies in xcode.
Then you have to make sure that this object persists as long as you need it, e. g. make it a property of the parent view controller.
There was error because I was using RestKit Object loader and RestKit client to load two different urls from the same controller at the same time. And both of them would call the request delegate at first. So, the json I was expecting the requestDidLoad delegate was different as it also loaded the same delegate for objectDidLoad at first. This has been fixed now.

NSInvalidArgumentException', reason: '-[__NSArrayM isValid]

can anyone tell me what may be the reason of crash.
Application Specific Information:
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM isValid]: unrecognized selector sent to instance 0x3f4a80'
You sent the selector isValid to an array, which doesn't respond to that message. That's all that can be said without seeing the code.
Here is my case,
to solve it:
Add -all_load to the other linker flags in your build settings.
-all_load forces the linker to load all object files from every archive it sees, even those without Objective-C code.
more description:
The "selector not recognized" runtime exception occurs due to an issue between the implementation of standard UNIX static libraries, the linker and the dynamic nature of Objective-C. Objective-C does not define linker symbols for each function (or method, in Objective-C) - instead, linker symbols are only generated for each class. If you extend a pre-existing class with categories, the linker does not know to associate the object code of the core class implementation and the category implementation. This prevents objects created in the resulting application from responding to a selector that is defined in the category.
To resolve this issue, the target linking against the static library must pass the -ObjC option to the linker. This flag causes the linker to load every object file in the library that defines an Objective-C class or category. While this option will typically result in a larger executable (due to additional object code loaded into the application), it will allow the successful creation of effective Objective-C static libraries that contain categories on existing classes. Follow these steps to pass -ObjC to the linker:
In Xcode, double-click the target's name under "Targets"
in the Project window.Choose the Build pane from the ensuing Info window.
Scroll down to the Other Linker Flags build setting under the Linking collection and set its value to -ObjC.