iOS Question CS builder trying to convert B4A to B4I

tsteward

Well-Known Member
Licensed User
Longtime User
In converting my app I'm not sure why this code crashes. Partly because I don't understand CSbuilder but ide does not show any error.
B4X:
Dim cs As CSBuilder
            cs.Initialize.Color(Colors.Black).Append(Code & " > ")
            Dim endLength As Int = cutsLegendSideA.Length - 1
            Dim startpos As Int = 0
            If B4XPages.MainPage.currentTool = "HU83" Then
                startpos = 1
            End If
            For i = startpos To endLength
                If CutsA(i).Text.Contains(Bitting.CharAt(i-startpos)) Then
                    #if b4a
                    cs.Bold.Color(Colors.White).Append(Bitting.CharAt(i-startpos)).Pop.Pop
                    #else if b4i
'**** Errors here ****'
                    cs.Color(Colors.White).Append(Bitting.CharAt(i-startpos)).Pop.Pop
                    #End If
                Else
                    #if B4A
                     cs.Bold.Color(Colors.rgb(49,45,45)).Append(Bitting.CharAt(i-startpos)).Pop.Pop
                     #else if B4I
                    cs.Color(Colors.rgb(49,45,45)).Append(Bitting.CharAt(i-startpos)).Pop.Pop
                     #end if
                End If
            Next
            If cutsLegendSideB.Length > 0 Then
                cs.Color(Colors.Black).Append("-").pop
            End If
            For i = 0 To cutsLegendSideB.Length - 1
                If CutsB(i).Text.Contains(Bitting.CharAt(cutsLegendSideA.Length + i + 1)) Then
                    #if B4A
                     cs.Bold.Color(Colors.White).Append(Bitting.CharAt(cutsLegendSideA.Length + i + 1)).Pop.Pop
                     #else if B4I
                    cs.Color(Colors.White).Append(Bitting.CharAt(cutsLegendSideA.Length + i + 1)).Pop.Pop
                     #end if
                Else
                    #if B4A
                     cs.Bold.Color(Colors.rgb(49,45,45)).Append(Bitting.CharAt(cutsLegendSideA.Length + i + 1)).Pop.Pop
                     #else if B4I
                    cs.Color(Colors.rgb(49,45,45)).Append(Bitting.CharAt(cutsLegendSideA.Length + i + 1)).Pop.Pop
                     #end if
                End If
            Next
            cs.PopAll
            Tree.AddItem(keyblank,cs,Null,"")

Error
Error occurred on line: 1418 (B4XPageTools)
*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil
Stack Trace: (
CoreFoundation __exceptionPreprocess + 242
libobjc.A.dylib objc_exception_throw + 62
CoreFoundation -[__NSArrayM removeObjectAtIndex:] + 0
LARA5 -[B4ICSBuilder Pop] + 246
CoreFoundation __invoking___ + 140
CoreFoundation -[NSInvocation invoke] + 302
LARA5 +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1519
LARA5 -[B4IShell runVoidMethod] + 185
LARA5 -[B4IShell raiseEventImpl:method:args::] + 1721
LARA5 -[B4IShellBI raiseEvent:event:params:] + 1350
LARA5 -[b4i_b4xpagetools _beginkeysearch:] + 249
LARA5 -[ResumableSub_b4xpagetools_CheckBitting resume::] + 29290
CoreFoundation __invoking___ + 140
CoreFoundation -[NSInvocation invoke] + 302
LARA5 +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1519
LARA5 -[B4IShell runMethod:] + 376
LARA5 -[B4IShell raiseEventImpl:method:args::] + 1624
LARA5 -[B4IShellBI raiseEvent:event:params:] + 1350
LARA5 -[B4IDelegatableResumableSub resume::] + 363
LARA5 -[B4I checkAndRunWaitForEvent:event:params:] + 482
LARA5 -[B4IShellBI raiseEvent:event:params:] + 1198
LARA5 -[B4ICommon CallSub4::::] + 286
LARA5 -[B4ICommon CallSub2::::] + 299
LARA5 -[b4i_httpjob _complete::] + 691
LARA5 -[b4i_httputils2service _completejob::::] + 1459
LARA5 -[b4i_httputils2service _hc_responsesuccess::] + 478
CoreFoundation __invoking___ + 140
CoreFoundation -[NSInvocation invoke] + 302
LARA5 +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1519
LARA5 -[B4IShell runMethod:] + 376
LARA5 -[B4IShell raiseEventImpl:method:args::] + 1624
LARA5 -[B4IShellBI raiseEvent:event:params:] + 1350
LARA5 __61-[B4IHttp URLSession:downloadTask:didFinishDownloadingToURL:]_block_invoke + 304
libdispatch.dylib _dispatch_client_callout + 8
libdispatch.dylib _dispatch_async_and_wait_invoke + 109
libdispatch.dylib _dispatch_client_callout + 8
libdispatch.dylib _dispatch_main_queue_drain + 1417
libdispatch.dylib _dispatch_main_queue_callback_4CF + 31
CoreFoundation __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
CoreFoundation __CFRunLoopRun + 2515
CoreFoundation CFRunLoopRunSpecific + 536
GraphicsServices GSEventRunModal + 137
UIKitCore -[UIApplication _run] + 875
UIKitCore UIApplicationMain + 123
LARA5 main + 104
dyld start_sim + 10
??? 0x0 + 8607683277
)
 
Top