On Sat, Jun 18, 2016, at 11:56 PM, Tom Steward wrote:
> I am trying to build Objective-C static frameworks but ran into
> hierarchy/organization problems.

You talk about “static frameworks”, but then proceed to discuss
“classB.framework”, etc., implying you are actually talking about
dynamic frameworks. Which are you trying to achieve?

--Kyle Sluder

> 
> For the question, assume I have 3 classes, classA, classB, and classC.
> classB and classC are children classes of classA. classB and classC each
> needs special resource files.
> 
> #import "classB.h"
> #import "classC.h"
> @implement classA
> 
>   + (classA)factoryMethodCreateType:(NSString *)type {
>       classA a;
>       if ([type isEqualToString:@"classB"]) {
>         a = [[classB alloc] init];
>       } else if ([type isEqualToString:@"classC"]) {
>         a = [classC alloc] init];
>       }
>       return a;
>   }
> 
> @end
> 
> I'd like to statically package the frameworks, classB.framework and
> classC.framework, such that when a user wants to use classB, they don't
> need to include classC and its resource files. Additionally, the user can
> use classA as the entry point to use either of the frameworks.
> 
> I assume if I just create classB.framework (includes classA and classB)
> and
> classC.framework (includes classA and classC), when the user wants to use
> both types and include both frameworks, the user will face duplicate
> symbols?
> 
> What is the best way to handle this situation? Is the following approach
> the best way to do it?
> 
> Change classA's implementation to dynamic creation of classB or classC
> and
> not include their header files.
> 
> Build 3 frameworks instead of 2: classA.framework, classB.framework,
> classC.framework. When the user wants to use classB, the the user should
> include both classA.framework and classB.framework.
> 
> @implement classA
> + (classA)factoryMethodCreateType:(NSString *)type {
>     classA a;
> 
>     id obj = [NSClassFromString(type) alloc];
>     a = objc_msgSend(obj, @selector(init));
>     return a;
> }
> 
> @end

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to