Xcode debugger showing a property as ?












1















I'm inspecting an enum which has an init method:



init(cardholder: Cardholder?, topUpSettings: TopUpSettings?, cardUser: VenmoCardUser? = nil) {

switch (cardholder, topUpSettings, cardUser) {
case (nil, _, let cardUser?) where cardUser.isWhitelisted && cardUser.cardType == .paypal:
self = .readyToOnboard


The VenmoCardUser.cardType is itself a VenmoCardType:



public enum VenmoCardType: String, Codable {
case shift = "shift"
case paypal = "paypal"
}


I would expect the cardUser.cardType in this method to be "paypal", but I'm a bit confused by the debugger output:



Xcode debugging screenshot



The debugger inspector (the window on the bottom left) is showing cardUser multiple times; the bottommost occurrence shows the cardUser.cardType as shift, whereas the second-to-last shows it as <invalid>. If I evaluate expression cardUser.cardType in lldb, I seem to get <invalid>.



Can someone perhaps help me understand




  1. Why I am seeing cardUser twice in the debugger - what do the different occurrences represent?

  2. How can the value be <invalid>? Doesn't the enum have to be one of the permissible values shift or paypal?


Update



To answer my first question, I believe that the debugger re-evaluates the variables in scope every time you press the "Step over" button, and outputs them below the ones you saw before. Below, I've added another screenshot in which I restarted the emulator, hit the breakpoint, and pressed "Step over" until the green highlighting moved to the next case.



Xcode debugging screenshot



What still baffles me, however, is that cardUser.cardType starts out as paypal (in the magenta drop-down menu), but after I press "Step over" multiple times, it changes first to <invalid>, and ultimately to shift like in the bottommost occurrence in the original screenshot. How can I tell how or at what point this is happening?










share|improve this question





























    1















    I'm inspecting an enum which has an init method:



    init(cardholder: Cardholder?, topUpSettings: TopUpSettings?, cardUser: VenmoCardUser? = nil) {

    switch (cardholder, topUpSettings, cardUser) {
    case (nil, _, let cardUser?) where cardUser.isWhitelisted && cardUser.cardType == .paypal:
    self = .readyToOnboard


    The VenmoCardUser.cardType is itself a VenmoCardType:



    public enum VenmoCardType: String, Codable {
    case shift = "shift"
    case paypal = "paypal"
    }


    I would expect the cardUser.cardType in this method to be "paypal", but I'm a bit confused by the debugger output:



    Xcode debugging screenshot



    The debugger inspector (the window on the bottom left) is showing cardUser multiple times; the bottommost occurrence shows the cardUser.cardType as shift, whereas the second-to-last shows it as <invalid>. If I evaluate expression cardUser.cardType in lldb, I seem to get <invalid>.



    Can someone perhaps help me understand




    1. Why I am seeing cardUser twice in the debugger - what do the different occurrences represent?

    2. How can the value be <invalid>? Doesn't the enum have to be one of the permissible values shift or paypal?


    Update



    To answer my first question, I believe that the debugger re-evaluates the variables in scope every time you press the "Step over" button, and outputs them below the ones you saw before. Below, I've added another screenshot in which I restarted the emulator, hit the breakpoint, and pressed "Step over" until the green highlighting moved to the next case.



    Xcode debugging screenshot



    What still baffles me, however, is that cardUser.cardType starts out as paypal (in the magenta drop-down menu), but after I press "Step over" multiple times, it changes first to <invalid>, and ultimately to shift like in the bottommost occurrence in the original screenshot. How can I tell how or at what point this is happening?










    share|improve this question



























      1












      1








      1








      I'm inspecting an enum which has an init method:



      init(cardholder: Cardholder?, topUpSettings: TopUpSettings?, cardUser: VenmoCardUser? = nil) {

      switch (cardholder, topUpSettings, cardUser) {
      case (nil, _, let cardUser?) where cardUser.isWhitelisted && cardUser.cardType == .paypal:
      self = .readyToOnboard


      The VenmoCardUser.cardType is itself a VenmoCardType:



      public enum VenmoCardType: String, Codable {
      case shift = "shift"
      case paypal = "paypal"
      }


      I would expect the cardUser.cardType in this method to be "paypal", but I'm a bit confused by the debugger output:



      Xcode debugging screenshot



      The debugger inspector (the window on the bottom left) is showing cardUser multiple times; the bottommost occurrence shows the cardUser.cardType as shift, whereas the second-to-last shows it as <invalid>. If I evaluate expression cardUser.cardType in lldb, I seem to get <invalid>.



      Can someone perhaps help me understand




      1. Why I am seeing cardUser twice in the debugger - what do the different occurrences represent?

      2. How can the value be <invalid>? Doesn't the enum have to be one of the permissible values shift or paypal?


      Update



      To answer my first question, I believe that the debugger re-evaluates the variables in scope every time you press the "Step over" button, and outputs them below the ones you saw before. Below, I've added another screenshot in which I restarted the emulator, hit the breakpoint, and pressed "Step over" until the green highlighting moved to the next case.



      Xcode debugging screenshot



      What still baffles me, however, is that cardUser.cardType starts out as paypal (in the magenta drop-down menu), but after I press "Step over" multiple times, it changes first to <invalid>, and ultimately to shift like in the bottommost occurrence in the original screenshot. How can I tell how or at what point this is happening?










      share|improve this question
















      I'm inspecting an enum which has an init method:



      init(cardholder: Cardholder?, topUpSettings: TopUpSettings?, cardUser: VenmoCardUser? = nil) {

      switch (cardholder, topUpSettings, cardUser) {
      case (nil, _, let cardUser?) where cardUser.isWhitelisted && cardUser.cardType == .paypal:
      self = .readyToOnboard


      The VenmoCardUser.cardType is itself a VenmoCardType:



      public enum VenmoCardType: String, Codable {
      case shift = "shift"
      case paypal = "paypal"
      }


      I would expect the cardUser.cardType in this method to be "paypal", but I'm a bit confused by the debugger output:



      Xcode debugging screenshot



      The debugger inspector (the window on the bottom left) is showing cardUser multiple times; the bottommost occurrence shows the cardUser.cardType as shift, whereas the second-to-last shows it as <invalid>. If I evaluate expression cardUser.cardType in lldb, I seem to get <invalid>.



      Can someone perhaps help me understand




      1. Why I am seeing cardUser twice in the debugger - what do the different occurrences represent?

      2. How can the value be <invalid>? Doesn't the enum have to be one of the permissible values shift or paypal?


      Update



      To answer my first question, I believe that the debugger re-evaluates the variables in scope every time you press the "Step over" button, and outputs them below the ones you saw before. Below, I've added another screenshot in which I restarted the emulator, hit the breakpoint, and pressed "Step over" until the green highlighting moved to the next case.



      Xcode debugging screenshot



      What still baffles me, however, is that cardUser.cardType starts out as paypal (in the magenta drop-down menu), but after I press "Step over" multiple times, it changes first to <invalid>, and ultimately to shift like in the bottommost occurrence in the original screenshot. How can I tell how or at what point this is happening?







      ios swift xcode






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 3 at 4:15









      shim

      4,10664780




      4,10664780










      asked Jan 2 at 21:21









      Kurt PeekKurt Peek

      10.9k2276162




      10.9k2276162
























          1 Answer
          1






          active

          oldest

          votes


















          1














          switch (cardholder, topUpSettings, cardUser) {
          //BREAK 1
          case (nil, _, let cardUser?) where cardUser.isWhitelisted && cardUser.cardType == .paypal:
          //BREAK 2 ON THE LINE ABOVE


          If we break on 1, we will see that if we print our cardUser it will return some value. In your case, it LOOKS like it should be paypal initially. However, when you step over and break on the next line of case(nil, _, let cardUser?)... you are ON the line of let cardUser? therefore, we don't yet KNOW what it is. You need to go to the NEXT line to determine what cardUser will be. When you step on to the line, it has not yet executed. You are on the line, therefore cardUser has not yet executed, but is about to.



          You are seeing 2 cardUser because you are USING 2 cardUser variables



          Try changing to this



          switch (cardholder, topUpSettings, cardUser) {
          case (nil, _, let differentCardUser) ...


          You will now see cardUser and differentCardUser. cardUser will have its value and differentCardUser will have its value AFTER you step over the initialization of it.






          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%2f54013341%2fxcode-debugger-showing-a-property-as-invalid%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









            1














            switch (cardholder, topUpSettings, cardUser) {
            //BREAK 1
            case (nil, _, let cardUser?) where cardUser.isWhitelisted && cardUser.cardType == .paypal:
            //BREAK 2 ON THE LINE ABOVE


            If we break on 1, we will see that if we print our cardUser it will return some value. In your case, it LOOKS like it should be paypal initially. However, when you step over and break on the next line of case(nil, _, let cardUser?)... you are ON the line of let cardUser? therefore, we don't yet KNOW what it is. You need to go to the NEXT line to determine what cardUser will be. When you step on to the line, it has not yet executed. You are on the line, therefore cardUser has not yet executed, but is about to.



            You are seeing 2 cardUser because you are USING 2 cardUser variables



            Try changing to this



            switch (cardholder, topUpSettings, cardUser) {
            case (nil, _, let differentCardUser) ...


            You will now see cardUser and differentCardUser. cardUser will have its value and differentCardUser will have its value AFTER you step over the initialization of it.






            share|improve this answer




























              1














              switch (cardholder, topUpSettings, cardUser) {
              //BREAK 1
              case (nil, _, let cardUser?) where cardUser.isWhitelisted && cardUser.cardType == .paypal:
              //BREAK 2 ON THE LINE ABOVE


              If we break on 1, we will see that if we print our cardUser it will return some value. In your case, it LOOKS like it should be paypal initially. However, when you step over and break on the next line of case(nil, _, let cardUser?)... you are ON the line of let cardUser? therefore, we don't yet KNOW what it is. You need to go to the NEXT line to determine what cardUser will be. When you step on to the line, it has not yet executed. You are on the line, therefore cardUser has not yet executed, but is about to.



              You are seeing 2 cardUser because you are USING 2 cardUser variables



              Try changing to this



              switch (cardholder, topUpSettings, cardUser) {
              case (nil, _, let differentCardUser) ...


              You will now see cardUser and differentCardUser. cardUser will have its value and differentCardUser will have its value AFTER you step over the initialization of it.






              share|improve this answer


























                1












                1








                1







                switch (cardholder, topUpSettings, cardUser) {
                //BREAK 1
                case (nil, _, let cardUser?) where cardUser.isWhitelisted && cardUser.cardType == .paypal:
                //BREAK 2 ON THE LINE ABOVE


                If we break on 1, we will see that if we print our cardUser it will return some value. In your case, it LOOKS like it should be paypal initially. However, when you step over and break on the next line of case(nil, _, let cardUser?)... you are ON the line of let cardUser? therefore, we don't yet KNOW what it is. You need to go to the NEXT line to determine what cardUser will be. When you step on to the line, it has not yet executed. You are on the line, therefore cardUser has not yet executed, but is about to.



                You are seeing 2 cardUser because you are USING 2 cardUser variables



                Try changing to this



                switch (cardholder, topUpSettings, cardUser) {
                case (nil, _, let differentCardUser) ...


                You will now see cardUser and differentCardUser. cardUser will have its value and differentCardUser will have its value AFTER you step over the initialization of it.






                share|improve this answer













                switch (cardholder, topUpSettings, cardUser) {
                //BREAK 1
                case (nil, _, let cardUser?) where cardUser.isWhitelisted && cardUser.cardType == .paypal:
                //BREAK 2 ON THE LINE ABOVE


                If we break on 1, we will see that if we print our cardUser it will return some value. In your case, it LOOKS like it should be paypal initially. However, when you step over and break on the next line of case(nil, _, let cardUser?)... you are ON the line of let cardUser? therefore, we don't yet KNOW what it is. You need to go to the NEXT line to determine what cardUser will be. When you step on to the line, it has not yet executed. You are on the line, therefore cardUser has not yet executed, but is about to.



                You are seeing 2 cardUser because you are USING 2 cardUser variables



                Try changing to this



                switch (cardholder, topUpSettings, cardUser) {
                case (nil, _, let differentCardUser) ...


                You will now see cardUser and differentCardUser. cardUser will have its value and differentCardUser will have its value AFTER you step over the initialization of it.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jan 2 at 22:30









                impression7vximpression7vx

                54911038




                54911038
































                    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%2f54013341%2fxcode-debugger-showing-a-property-as-invalid%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

                    MongoDB - Not Authorized To Execute Command

                    How to fix TextFormField cause rebuild widget in Flutter

                    Npm cannot find a required file even through it is in the searched directory