I have a private class (both declared & defined within .m) as an addition to an implementation of a different class, that happens to use that private class internally.
Managed to get this to work, it's pretty simple actually.
So the way I did it:
@interface NSObject(PrivateSwizzleCategory)
swizzled:
+(void)load
{
Method original, swizzled;
original = class_getInstanceMethod(objc_getClass("SomePrivateClass"), @selector(somePrivateMethod:));
swizzled = class_getInstanceMethod(self, @selector(swizzled_somePrivateMethod:));
method_exchangeImplementations(original, swizzled);
}
To call the original implementation, I had to cast self to NSObject:
id ret = [(NSObject *)self swizzled_somePrivateMethod:someParam];
To access private properties of the private class, I used valueForKey on self:
id privateProperty = [self valueForKey:@"__privateProperty"];
Everything works!