Code Monkey home page Code Monkey logo

Comments (12)

jverkoey avatar jverkoey commented on July 21, 2024

You need to use something like this macro found in Nimbus:

https://github.com/jverkoey/nimbus/blob/master/src/core/src/NIPreprocessorMacros.h#L48

from ios-framework.

boboboa32 avatar boboboa32 commented on July 21, 2024

hi, thank you for your reply. I write a test catagory like this:
————————————————————————————
#import "NSDictionary+SafeObject.h"
NI_FIX_CATEGORY_BUG(NSDictionarySafeObject)
@implementation NSDictionary (SafeObject)

  • (id)safeObjectForKey:(id)aKey {
    if (![[self objectForKey:aKey] isKindOfClass:[NSNull class]]) {
    return [self objectForKey:aKey];
    }
    else
    return nil;
    }
    @EnD
    ——————————————————————————————

But I still got the same error in console:
"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary safeObjectForKey:]: unrecognized selector sent to instance 0x68a3ac0'"

from ios-framework.

jverkoey avatar jverkoey commented on July 21, 2024

Also make sure that you are using the -Objc linker flag in your application.

from ios-framework.

baphillips avatar baphillips commented on July 21, 2024

Just to prevent confusion, the correct flag is -ObjC

from ios-framework.

sarperdag avatar sarperdag commented on July 21, 2024

I still have this issue, are you sure this works?

from ios-framework.

baphillips avatar baphillips commented on July 21, 2024

I was able to get this fix working however i didn't need the NI_FIX_CATEGORY_BUG macro.

from ios-framework.

jverkoey avatar jverkoey commented on July 21, 2024

Did you fix it by using -force_load or -all_load? If so, those flags are particularly dangerous and is why the NI_FIX_CATEGORY_BUG macro exists.

from ios-framework.

baphillips avatar baphillips commented on July 21, 2024

No I did not have to use -force_load or -all_load. I ran into this problem when I was using JSONKit in my framework. The "JSONKitSerializing", "JSONKitDeserializing", and "JSONKitSerializingBlockAdditions" categories were not loading and caused a problem similar to boboboa32's error (can not respond to the selector).

from ios-framework.

jverkoey avatar jverkoey commented on July 21, 2024

Ah ok. What was your fix then?

from ios-framework.

baphillips avatar baphillips commented on July 21, 2024

Simply by adding -ObjC to "Other Linker Flags" under the Build Settings tab of my project target (the project that is including the framework).

from ios-framework.

jverkoey avatar jverkoey commented on July 21, 2024

Sweet :)

from ios-framework.

paiv avatar paiv commented on July 21, 2024

I wonder, why -ObjC is still needed, whereas standard frameworks do not require it? What do we lack in this custom framework?

from ios-framework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.