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:
I define this class in the code module/page and call it with this code:
The "If File.Exists...." code starts at line 537. When I run the code directly I get the following error:
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
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:
B4X:
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 String) As 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:
B4X:
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 arams:] + 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 arams:] + 1580
Trial App __33-[B4I raiseUIEvent:event arams:]_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
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
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
Trial App __33-[B4I raiseUIEvent:event
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: