Categories in Objective-C aren't working Categories in Objective-C aren't working objective-c objective-c

Categories in Objective-C aren't working


It really seems like your category isn't being compiled or linked into the same target that you're using it from. You should make sure that NSData+Base64.m is marked to be compiled by the same target that it's being used from by getting info on the two files and comparing the targets they're assigned to.

A test you can perform is to add a line with an #error error message to NSData+Base64.m, which will cause the build to fail when it gets to that file. Like this:

#error We're now compiling NSData+Base64.m

Then look and see which target fails to compile.


I had the same issue with ARC project which was linking with non-ARC module having category extension.

Fixed the issue by adding "Other Linker Flags: -all_load" in parent ARC project.


Have you #imported the header file for your category? I know it sounds simple, but I forget nearly every time.