iOS Question [Solved] Attempted to insert nil object - File.Exists

Discussion in 'iOS Questions' started by hatzisn, Apr 13, 2019.

  1. hatzisn

    hatzisn Active Member Licensed User

    Hi everyone,

    I have this problem. I have created a class which is named RuntimePermissions in order to create a sub GetSafeDirDefaultExternal(Folder as String). The class is the following:

    Code:
    Sub Class_Globals
     
    End Sub

    'Initializes the object. You can add parameters to this method if needed.
    Public Sub Initialize
     
    End Sub

    Public Sub GetSafeDirDefaultExternal(Folder As StringAs String
     
        
    Log(File.DirDocuments & Folder)
        
    If Folder <> "" Then
    '        If File.Exists(File.DirDocuments & Folder, "") = False Then
    '            File.MakeDir(File.DirDocuments, Folder)
    '        End If
            Return File.DirDocuments & Folder
        
    Else
            
    Return File.DirDocuments
        
    End If
     
     
    End Sub

    I define this class in the code module/page and call it with this code:

    Code:
    If File.Exists(rp.GetSafeDirDefaultExternal("Guide"),"") = False Then
            
    File.MakeDir(rp.GetSafeDirDefaultExternal(""), "Guide")
        
    End If
    The "If File.Exists...." code starts at line 537. When I run the code directly I get the following error:

    Application_Start
    Error occurred on line: 537 (Main)
    *** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]
    Stack Trace: (
    CoreFoundation <redacted> + 252
    libobjc.A.dylib objc_exception_throw + 56
    CoreFoundation _CFArgv + 0
    CoreFoundation <redacted> + 284
    CoreFoundation <redacted> + 52
    Trial App -[B4IFile Combine::] + 184
    Trial App -[B4IFile Exists::] + 216
    Trial App -[ResumableSub_main_RunFromActivityCreate resume::] + 672
    Trial App -[b4i_main _runfromactivitycreate] + 368
    Trial App -[ResumableSub_main_CheckIfActivationIsStillActive resume::] + 7128
    Trial App -[b4i_main _checkifactivationisstillactive] + 368
    CoreFoundation <redacted> + 144
    CoreFoundation <redacted> + 292
    Trial App +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
    Trial App -[B4IShell runMethod:] + 448
    Trial App -[B4IShell raiseEventImpl:method:args::] + 2172
    Trial App -[B4IShellBI raiseEvent:event:params:] + 1580
    Trial App +[B4IDebug delegate:::] + 80
    Trial App -[b4i_main _activity_create:] + 360
    Trial App -[b4i_main _application_start:] + 1748
    CoreFoundation <redacted> + 144
    CoreFoundation <redacted> + 292
    Trial App +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1624
    Trial App -[B4IShell runMethod:] + 448
    Trial App -[B4IShell raiseEventImpl:method:args::] + 2172
    Trial App -[B4IShellBI raiseEvent:event:params:] + 1580
    Trial App __33-[B4I raiseUIEvent:event:params:]_block_invoke + 60
    libdispatch.dylib <redacted> + 24
    libdispatch.dylib <redacted> + 16
    libdispatch.dylib <redacted> + 1068
    CoreFoundation <redacted> + 12
    CoreFoundation <redacted> + 1924
    CoreFoundation CFRunLoopRunSpecific + 436
    GraphicsServices GSEventRunModal + 104
    UIKitCore UIApplicationMain + 212
    Trial App main + 124
    libdyld.dylib <redacted> + 4
    )

    Application_Active

    On the contrary when I run the same code with a breakpoint in this line and step into this code it works perfect. Any suggestions anyone?

    Thanks in advance
     
    Last edited: Apr 13, 2019
  2. hatzisn

    hatzisn Active Member Licensed User

    Strangely if I add a
    Code:
    Sleep(400)
    command it works perfect...
     
  3. hatzisn

    hatzisn Active Member Licensed User

    Not working again after a clean project. Same error...
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Please upload a small project with this class.
     
  5. hatzisn

    hatzisn Active Member Licensed User

    Hi Erel, can you write to me with a private message your e-mail to send you the code so far. I do not want to post it here.
     
  6. hatzisn

    hatzisn Active Member Licensed User

    Never mind I will try to create a new project and send it here.
     
  7. hatzisn

    hatzisn Active Member Licensed User

    I just figured out that working hours must have limits because if you go way too far with it, mistakes pop up like pop corns.
    It seems that I forgot to initialize the class but I cannot understand since I did not initialize it how did it work with the Breakpoint and F8?
     
    Last edited: Apr 14, 2019
  8. Erel

    Erel Administrator Staff Member Licensed User

    The debugger uses ~2 different execution pipelines. In some edge cases the behavior between the different channels is not exactly the same. Adding a breakpoint (or modifying the code of the relevant sub) will cause the program to run through a different pipeline.
     
    hatzisn likes this.
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