I am new to the POD project. I want to update the pod project viewControllers,for that I need to access the AppDelegate class in Pod Project.
I have tried to update the Pod configuration file to access the AppDelegate but not able to get success.
You really don't want to create a circular dependency between your app and the pod. The recommended way to do this would be to define a protocol in the pod and make your AppDelegate implement that protocol.
@protocol PodArrayProvider
- (NSArray *)arrayToAccess:
@end
// in AppDelegate.m
#import <Pod/Pod.h>
@extension AppDelegate () <PodArrayProvider>
@end
@implementation AppDelegate
- (NSArray *)arrayToAccess
{
return self.realArray;
}
@end
// then in your pod, you can do:
id<PodArrayProvider> arrayProvider = (id<PodArrayProvider>)[[UIApplication sharedApplication] delegate];
NSAssert([arrayProvider conformsTo:@protocol(PodArrayProvider)], @"bad app delegate!");
NSArray *things = [arrayProvider arrayToAccess];
Something like the structure above should work, but I would urge you to rethink this architecture. The pod is a dependency of the app and shouldn't know anything about the app. The app should be telling the pod everything it needs to know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With