arbesfeld
arbesfeld

Reputation: 103

Call non-exported method from static library

I am using a static library built by someone else in my Objective-C project. There is a C method in the library that I want to call, but it is not exported. How can a call this method from Objective-C code?

Upvotes: 0

Views: 252

Answers (1)

Amin Negm-Awad
Amin Negm-Awad

Reputation: 16660

First of all: Why do you need that? Obviously the author of that framework did not see any need for this and things can break, if a method is executed directly.

However: Write a category on the receiver with that method and just do it. Objective-C binds dynamically, so this works.

@interface FrameworkClass(InternalMethodAddition)
- (void)internalMethod;
@end
// Do not implement this category.
…
FrameworkClass *object = …
[object internalMethod];

Upvotes: 1

Related Questions