Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

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

    Mobile and Embedded
    4
    8
    4502
    Loading More Posts
    • 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
      vkjr last edited by

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • V
          vkjr last edited by

          [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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • V
              vkjr last edited by

              Sure, I understand, thank you!

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                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 Reply Quote 0
                • H
                  hamer last edited by

                  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 Reply Quote 1
                  • M
                    Markus Goetz53 last edited by

                    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 Reply Quote 2
                    • First post
                      Last post