Reputation: 2746
today I faced an odd issue. I used OAuthConsummer in my project to connect to Twitter. There are several versions of this Consummer and in my project, it has some header files (.h) and one file with .a extension. I want to subclass a class named "OAMutableURLRequest" and override some old methods, so I add two files: the header file and the implmentation file with overridden methods. This solution works for me for a long time. However, today when built on iOS 7 with Xcode 5.0.1, my app crashed with error that my overridden methods not exists (NSInvalidArgumentException).
So in summary, my question is that: How can I subclass a class that belongs to a library with only headers and files .a ?
Upvotes: 0
Views: 249
Reputation: 788
Yes you can! if you think about Apple frameworks, are nothing else than headers and precompiled libraries...
If you have a runtime crash in iOS7 check for some method has been removed or changed, or maybe you are calling method of your subclass over an instance of the superclass... if you want completelly overwrite a method behaviour and you don't care at all about the method implementation of the original class you can create a category on the original class, Attention! Because you won't be able to access the original implementation of the method, and in categories in not possible to add new class member (ivar)! But you can always call the super class implementation if the method exist in the super class
Upvotes: 1