How to add optional delegates with #if canImport() enabled?How to change the name of an iOS app?How do I create delegates in Objective-C?How can I make a UITextField move up when the keyboard is present - on starting to edit?How to tell if UIViewController's view is visibleWhat kind of leaks does automatic reference counting in Objective-C not prevent or minimize?weak or strong properties for my sub-viewControllers?How to architect 'State Controller' objects being delegates of shared servicesCustom init for UIViewController in Swift with interface setup in storyboardhow to programmatically create segue for use with Protocol & Delegate (swift 3 xcode)Delegate retention circle although using weak

GFCI outlets - can they be repaired? Are they really needed at the end of a circuit?

Machine learning testing data

What Exploit Are These User Agents Trying to Use?

What is the opposite of "eschatology"?

Bullying boss launched a smear campaign and made me unemployable

In the UK, is it possible to get a referendum by a court decision?

Obtaining database information and values in extended properties

When handwriting 黄 (huáng; yellow) is it incorrect to have a disconnected 草 (cǎo; grass) radical on top?

Can I hook these wires up to find the connection to a dead outlet?

Car headlights in a world without electricity

What historical events would have to change in order to make 19th century "steampunk" technology possible?

Standard deduction V. mortgage interest deduction - is it basically only for the rich?

My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?

Should I tell management that I intend to leave due to bad software development practices?

What is an equivalently powerful replacement spell for Yuan-Ti's Suggestion spell?

Why was the shrink from 8″ made only to 5.25″ and not smaller (4″ or less)

What are the G forces leaving Earth orbit?

files created then deleted at every second in tmp directory

Could the museum Saturn V's be refitted for one more flight?

Convert seconds to minutes

How do conventional missiles fly?

Why is it a bad idea to hire a hitman to eliminate most corrupt politicians?

What does the same-ish mean?

Am I breaking OOP practice with this architecture?



How to add optional delegates with #if canImport() enabled?


How to change the name of an iOS app?How do I create delegates in Objective-C?How can I make a UITextField move up when the keyboard is present - on starting to edit?How to tell if UIViewController's view is visibleWhat kind of leaks does automatic reference counting in Objective-C not prevent or minimize?weak or strong properties for my sub-viewControllers?How to architect 'State Controller' objects being delegates of shared servicesCustom init for UIViewController in Swift with interface setup in storyboardhow to programmatically create segue for use with Protocol & Delegate (swift 3 xcode)Delegate retention circle although using weak













0















how to add optional delegates between #ifCan compiler tags?



Here what I need t do:



#if canImport(optionalFramework)
//adding optional delegate
class ViewController: UIViewController, OptionalDelagate
#else
//no need for delagete
    class ViewController: UIViewController
#endif


Such feature if possible would really be crucial and would really improve whole application design.. However, I am getting multiple compiler errors..



I tried to create separate class,which would use this delegate, but I can't remove it, and I am getting memory leaks, because of strong references.



Thanks as always :)










share|improve this question




























    0















    how to add optional delegates between #ifCan compiler tags?



    Here what I need t do:



    #if canImport(optionalFramework)
    //adding optional delegate
    class ViewController: UIViewController, OptionalDelagate
    #else
    //no need for delagete
        class ViewController: UIViewController
    #endif


    Such feature if possible would really be crucial and would really improve whole application design.. However, I am getting multiple compiler errors..



    I tried to create separate class,which would use this delegate, but I can't remove it, and I am getting memory leaks, because of strong references.



    Thanks as always :)










    share|improve this question


























      0












      0








      0








      how to add optional delegates between #ifCan compiler tags?



      Here what I need t do:



      #if canImport(optionalFramework)
      //adding optional delegate
      class ViewController: UIViewController, OptionalDelagate
      #else
      //no need for delagete
          class ViewController: UIViewController
      #endif


      Such feature if possible would really be crucial and would really improve whole application design.. However, I am getting multiple compiler errors..



      I tried to create separate class,which would use this delegate, but I can't remove it, and I am getting memory leaks, because of strong references.



      Thanks as always :)










      share|improve this question
















      how to add optional delegates between #ifCan compiler tags?



      Here what I need t do:



      #if canImport(optionalFramework)
      //adding optional delegate
      class ViewController: UIViewController, OptionalDelagate
      #else
      //no need for delagete
          class ViewController: UIViewController
      #endif


      Such feature if possible would really be crucial and would really improve whole application design.. However, I am getting multiple compiler errors..



      I tried to create separate class,which would use this delegate, but I can't remove it, and I am getting memory leaks, because of strong references.



      Thanks as always :)







      ios swift uiviewcontroller protocols






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 21:03







      Viktor Vostrikov

















      asked Mar 7 at 20:51









      Viktor VostrikovViktor Vostrikov

      591113




      591113






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Move the delegate definition into an extension:



          #if canImport(optionalFramework)
          extension ViewController: OptionalDelegate


          #endif





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55052598%2fhow-to-add-optional-delegates-with-if-canimport-enabled%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Move the delegate definition into an extension:



            #if canImport(optionalFramework)
            extension ViewController: OptionalDelegate


            #endif





            share|improve this answer



























              0














              Move the delegate definition into an extension:



              #if canImport(optionalFramework)
              extension ViewController: OptionalDelegate


              #endif





              share|improve this answer

























                0












                0








                0







                Move the delegate definition into an extension:



                #if canImport(optionalFramework)
                extension ViewController: OptionalDelegate


                #endif





                share|improve this answer













                Move the delegate definition into an extension:



                #if canImport(optionalFramework)
                extension ViewController: OptionalDelegate


                #endif






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 7 at 21:19









                Rob NapierRob Napier

                206k28305433




                206k28305433





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55052598%2fhow-to-add-optional-delegates-with-if-canimport-enabled%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

                    Алба-Юлія

                    Захаров Федір Захарович