To be honest I don’t know how to call it, so I’ll try to describe it.
UIApplicationDelegate protocol has “application:handleOpenURL:” method. And if I implement this method in my ApplicationDelegate class, it will be called when somebody opens my urls.
However, I’d like my other class (uiviewcontroller) to receive this call. To make a different example – you can create a few classes and each of them can get GPS position. Is it possible to do the same with UIApplicationDelegate protocol?
I searched a lot for this topic here, but I couldn’t find any answer on how to do it. I know how to get my application delegate ([[UIApplication sharedApplication] delegate]), but it’s not the case in this situation.
You can always tell somebody who came to objective-c from some other object oriented language, because their first instinct is to subclass, subclass, subclass. There’s not a lot of subclassing in obj-c. You CAN, obviously, but it’s not how things are conventionally done, especially with things that are as one-shot-ish as UIApplicationDelegate. The more Cocoaish Way is to use categories, or sometimes to create a new NSObject subclass that contains the would-be parent class as a property.
In this case, for sure subclassing is a bad idea. the UIApplication singleton can only have one delegate property. So if you create a new UIApplicationDelegate, you’ve got no place to hook to it.
Instead, smarten up your one delegate’s
application:handleOpenURL:method to catch the URL call and load up whichever UIViewController subclass (I know, I know: exceptions) is going to handle it.