Bug? StringBuilder working on native immutable string?

boastrike

Member
Licensed User
Longtime User
While using the string builder I came across an error, it appears as though some of the StringBuilder subs are not working correctly. The error is at line 105 which I have highlighted red.

Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
Case "selectOrders"
Dim selectOrderResponse As String
selectOrderResponse = Job.GetString
If selectOrderResponse.Length > 0 Then
ResultScroll.Panel.RemoveAllViews
SelectOrderResultList.Initialize
SelectOrderResultViewCollection.Initialize
JSONTool.Initialize(selectOrderResponse)

SelectOrderResultList = JSONTool.NextArray

Dim yOffset As Float
For index = 0 To SelectOrderResultList.Size - 1
yOffset = index * 100
ResultScroll.ContentHeight = yOffset + 100
ResultScroll.Panel.Width = ResultScroll.Width
ResultScroll.Panel.Height = yOffset + 100

Dim resultPanel As Panel
Dim resultLabelTop As Label
Dim resultLabelBottom As Label
Dim adHoc As Map

resultLabelTop.Initialize("")
resultLabelTop.Width = ResultScroll.Width
resultLabelTop.Height = 50
adHoc.Initialize
adHoc = SelectOrderResultList.Get(index)
resultLabelTop.TextColor = Colors.White

StringTool = adHoc.Get("OrderTime")
resultLabelTop.Text = StringTool.Remove(0, StringTool.Length - 11) & ": " & adHoc.Get("OrderNumber") & " - $"
StringTool = adHoc.Get("GrandTotal")
resultLabelTop.Text = resultLabelTop.Text & StringTool.Remove(StringTool.Length - 2, StringTool.Length)

resultLabelBottom.Initialize("")
resultLabelBottom.Width = ResultScroll.Width
resultLabelBottom.Height = 50
adHoc.Initialize
adHoc = SelectOrderResultList.Get(index)

StringTool = adHoc.Get("Discount")
Select adHoc.Get("CartID")
Case "0"
resultLabelBottom.Text = "Point of Sale Discount $"
resultLabelBottom.Text = resultLabelBottom.Text & StringTool.Remove(StringTool.Length - 2, StringTool.Length)
End Select

resultPanel.Initialize("resultPanel")
resultPanel.Width = ResultScroll.Width
resultPanel.Height = 100

resultPanel.AddView(resultLabelTop, 0, 0, ResultScroll.Width, 50)
resultPanel.AddView(resultLabelBottom, 0, 50, ResultScroll.Width, 50)

SelectOrderResultViewCollection.Add(resultPanel)
ResultScroll.Panel.AddView(resultPanel, 0, yOffset, ResultScroll.Width, 100)
Next
Else
Toast.ToastMessageShow("No results found.", True)
End If
End Select
Else
Log("Error: " & Job.ErrorMessage)
Toast.ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub


Error Message:

Application_Start
Application_Active
JobName = selectOrders, Success = true
Error occurred on line: 105 (sales)
Attempt to mutate immutable object with deleteCharactersInRange:
Stack Trace: (
CoreFoundation <redacted> + 150
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 0
CoreFoundation <redacted> + 112
Stone Cold -[B4IStringBuilder Remove::] + 96
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 300
Stone Cold +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1936
Stone Cold -[B4IShell runMethod:] + 496
Stone Cold -[B4IShell raiseEventImpl:method:args::] + 1846
Stone Cold -[B4IShellBI raiseEvent:event:params:] + 1280
Stone Cold -[B4ICommon CallSub4::::] + 346
Stone Cold -[B4ICommon CallSub2::::] + 254
Stone Cold -[b4i_httpjob _complete::] + 414
Stone Cold -[b4i_httputils2service _completejob::::] + 752
Stone Cold -[b4i_httputils2service _hc_responsesuccess::] + 296
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 300
Stone Cold +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1936
Stone Cold -[B4IShell runMethod:] + 496
Stone Cold -[B4IShell raiseEventImpl:method:args::] + 2060
Stone Cold -[B4IShellBI raiseEvent:event:params:] + 1280
Stone Cold __61-[B4IHttp URLSession:downloadTask:didFinishDownloadingToURL:]_block_invoke + 244
libdispatch.dylib <redacted> + 368
libdispatch.dylib <redacted> + 22
libdispatch.dylib <redacted> + 712
CoreFoundation <redacted> + 8
CoreFoundation <redacted> + 1512
CoreFoundation CFRunLoopRunSpecific + 476
CoreFoundation CFRunLoopRunInMode + 106
GraphicsServices GSEventRunModal + 136
UIKit UIApplicationMain + 1440
Stone Cold main + 116
libdyld.dylib <redacted> + 2
)
 

boastrike

Member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

Where is the code that adds the mutable strings to adHoc map?

Thanks for responding. I changed the way I used the string builder and it seems to be working fine.
 
Top