ios - How to use an internal method in a Objective-C category? -
trying extend capabilities open source project, wrote category add new method. in new method, category needs access internal method original class, compiler says can't find method (of course, internal). there way expose method category?
edit
i don't want modify original code, don't want declare internal method in original class header file.
the code
in original class implementation file (.m), have method implementation:
+(nsdictionary*) storekititems { return [nsdictionary dictionarywithcontentsoffile: [[[nsbundle mainbundle] resourcepath] stringbyappendingpathcomponent: @"mkstorekitconfigs.plist"]]; }
in category, want add method:
- (void)requestproductdata:(nsarray *(^)())loadidentifierblock { nsmutablearray *productsarray = [nsmutablearray array]; nsarray *consumables = [[[mkstoremanager storekititems] objectforkey:@"consumables"] allkeys]; nsarray *nonconsumables = [[mkstoremanager storekititems] objectforkey:@"non-consumables"]; nsarray *subscriptions = [[[mkstoremanager storekititems] objectforkey:@"subscriptions"] allkeys]; if(loadidentifierblock != nil) [productsarray addobjectsfromarray:loadidentifierblock()]; [productsarray addobjectsfromarray:consumables]; [productsarray addobjectsfromarray:nonconsumables]; [productsarray addobjectsfromarray:subscriptions]; self.productsrequest.delegate = self; [self.productsrequest start]; }
in every line in call storekititems
compiler says: class method "+storekititems" not found ...
a category has no access private methods of class. it's no different trying call methods other class. @ least if call private method directly. since objective-c dynamic, can call private methods (which bad idea) using other means such using performselector
or nsinvocation
.
again, bad idea. update implementation of class break category.
edit: there code posted -
since +storekititems
method not declared in .h file, no category or other class can access private method.
Comments
Post a Comment