Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. [SOLVED] How to extend QIOSApplicationDelegate with category on ios?

[SOLVED] How to extend QIOSApplicationDelegate with category on ios?

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 4 Posters 5.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vkjr
    wrote on last edited by
    #1

    Hi!

    I have qt application for iOS and trying to add functions to application delegate. Guys on "this link":http://www.cutehacks.com/blog/2014/06/06/using-qt-to-build-an-omi-app-for-ios-and-android suggest to use categories to extend QIOSApplicationDelegate with own functionality.
    Like this:

    @#import "QIOSApplicationDelegate+OmiAppDelegate.h"
    #import <FacebookSDK/FacebookSDK.h>

    @implementation QIOSApplicationDelegate (OmiAppDelegate)

    • (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation
      {
      return [FBAppCall handleOpenURL:url sourceApplication:sourceApplication];
      }

    @end@

    But when I write own category I'm getting error that QIOSApplicationDelegate is unknown.
    What header or plugin should I include to make it known? (I searched for "qiosapplicationdelegate.h" on hard drive but didn't find it).

    Thanks!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      QIOSApplicationDelegate is in qtbase/src/plugins/platforms/ios

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vkjr
        wrote on last edited by
        #3

        [quote author="SGaist" date="1410897385"]Hi,

        QIOSApplicationDelegate is in qtbase/src/plugins/platforms/ios[/quote]

        Thank you, I just copied this and one more header to the project and it works :)

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Beware that's pretty dangerous, next iteration of Qt might have this header changed so you might end up with an "invalid" delegate

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vkjr
            wrote on last edited by
            #5

            Sure, I understand, thank you!

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You're welcome !

              Since you have your delegate working now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • H Offline
                H Offline
                hamer
                wrote on last edited by
                #7

                If somehow has the same problem. It sufficies to add this code instead of copying/including the private header:

                @interface QIOSApplicationDelegate
                @end
                
                1 Reply Last reply
                1
                • M Offline
                  M Offline
                  Markus Goetz53
                  wrote on last edited by
                  #8

                  Complete Code:

                  In the .pro:

                      ios {
                          OBJECTIVE_SOURCES = ios/ios_app_delegate.mm
                      }
                  

                  In ios/ios_app_delegate.mm:

                  #import "UIKit/UIKit.h"
                  
                  @interface QIOSApplicationDelegate
                  @end
                  
                  @interface QIOSApplicationDelegate (WoboqApplicationDelegate)
                  @end
                  
                  @implementation QIOSApplicationDelegate (WoboqApplicationDelegate)
                  
                  - (BOOL)application:(UIApplication *)application
                      didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
                      NSLog(@"launch!");
                      return YES;
                  }
                  
                  
                  @end
                  
                  
                  1 Reply Last reply
                  2

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved