0

I have three Xcode projects and I want to integrate them into one project. Two of those projects are view based application, hence the application delegate has inherited NSObject and UIApplicationDelegate. But the third project is not a view based application and so the app delegate has inherited UIApplication.

So now I am in a fix. How should I integrate the three of them, because if I try to make my third class inherit NSObject then there are many errors. And even if I deal with those errors, the app crashes during run time giving the exception:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There can only be one UIApplication instance.'

So what do I do now?

halfer
  • 19,824
  • 17
  • 99
  • 186
Jayshree
  • 281
  • 1
  • 6
  • 28
  • 1
    It makes absolutely no sense for an application delegate to inherit from `UIApplication`. – Ole Begemann Dec 10 '10 at 11:55
  • the uiapplication has been inherited because properties like networkActivityIndicatorVisible, statusBarStyle etc have to be used application delegate itself. And there are no xib files in this project. everything has been done programatically. even the main window is invoked through coding. So plz somebody help me. its kinda urgent. – Jayshree Dec 13 '10 at 13:48

1 Answers1

4

You shouldn't be inheriting from UIApplicationDelegate, but instead implementing the UIApplicationDelegate protocol.

Example:

@interface SampleAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *window;
    MainViewController *mainViewController;
}
Eric Reid
  • 457
  • 3
  • 10
  • yes i have implemented not inherited. I did not explain properly, my bad. but the problem still persists. i somehow have to make my third app inherit nsobject. – Jayshree Dec 13 '10 at 04:59
  • 1
    You'll have to post some code if you want us to be able to help you more. – Eric Reid Dec 14 '10 at 15:31