iOS Question Strange problem with code

Discussion in 'iOS Questions' started by Brian Robinson, Feb 11, 2015.

  1. Brian Robinson

    Brian Robinson Active Member Licensed User

    Hi All,

    I am currently converting my iPark app from Android to be used on the iPhone, but I have hit a major snag and was hoping for some help. I have pulled what I can out of my app and built a test app that shows the same behaviour. The problem I have is that when I run the app on my device with the debugger and I don't set any break points it has a problem parsing the JSON file. When I set break points and step through the code it parses the JSON correctly and creates all my objects as they should be. I have also tried creating a release build and that also fails. I was hoping someone could replicate this problem using the test app I have attached. Thanks for any help you can give.

    Cheers
    Brian
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    You must call the Initialize method of a class. The Initialize2 sub you created is not enough. You still need to call Initialize.

    However in this case you can just remove Initialize2 and use Initialize with this code:
    Code:
    Public Sub Initialize(jsonMap As Map)
       ReadFromZoneMap(jsonMap)
    End Sub
     
  3. Brian Robinson

    Brian Robinson Active Member Licensed User

    Ahhh... Ok, my mistake. I thought they were sort of overridable like a normal constructor, but when I think about it logically, they can't be. I always assumed that unless you were doing something in the Initialize sub you didn't need to call it, but only Dim it. I guess what I should be doing is calling the actual constructor "Initialize" in my Initialize2 Sub (but is there a problem with that, can't access my computer at the moment to test, but I have a feeling I have tried that before). I do still need a sub that creates an instance of the class that remains blank.

    Can you tell me why the code works when I step through it in the debugger, and not when I step over it? Very interested in this, even if the response is complicated.

    Thanks so much for your help with this one Erel, I was pulling at hair I no longer have. The strange thing was that I just pulled the code from my B4A project, but I will have to look again to see if I did any refactoring and stuffed it up.

    Cheers
    Brian
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    The rapid debugger is made of several layers. When there is no breakpoint (and the sub code is "up to date") the execution path used is a different, much faster, path. So in come edge cases the behavior can be different.
     
  5. Brian Robinson

    Brian Robinson Active Member Licensed User

    Hi Erel,

    Thanks for the answer. I understand, I find similar circumstances with the .Net debugger when optimisations are turned on.

    The fix worked for the demo app, but not for the actual app, I guess I will have to go through and check if there are othe itemsI
    Just to clarify as well for others, I was able to call the Initialize sub from within the Initialize2 sub. I thought I had experienced a problem doing this before in B4A, but I was wrong.

    I did check the B4A code and it isn't calling the Initialize, so not sure how it works.

    Just writing these ramblings in case someone else has the same problem

    Cheers
    Brian
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice