Exclude whole category of Objective-C class

I know that it is possible to set __deprecated attribute to category.

Is it possible to exclude whole category of Objective-C class by, for example, exclude attribute?

__attribute__((unavailable)) (or UNAVAILABLE_ATTRIBUTE in Apple headers) might do what you want. There's also NS_SWIFT_UNAVAILABLE if you just want to mark things unavailable from Swift.

Did you try it?

I mark category interface in header as unavailable and still have category symbols in Swift.

Another option...

// Swift should see nothing.

@interface MyObject (CategoryName)
- (void)someCategoryMethod;

1 Like
Terms of Service

Privacy Policy

Cookie Policy