iOS Question App Crash - Help Please


Licensed User

I kindly need some help please. Here is my app source:

It runs well however just crashes when I go back to the second page. I have checked the crash logs, as per advise from here

Its all greek to me. (Thought I could see something glaring)

I’m still new to B4i so I’m not sure whether its my code but nothing shows on debug.

Thanks for your help.

Warm Regards


Well-Known Member
Licensed User

I find the following error: see error.png

I solved the issue in Sub Json2Map in b4iMash with:

Sub Json2Map(strJSON As String) As Map
   ' convert a json string to a map
   Dim jList As List
   Dim JSON As JSONParser
   jList = JSON.NextArray

   Dim Entry As String = jList.Get(0)
   Dim KeyValuePairs() As String = Regex.Split("\" & CRLF,Entry)

   Dim jMap As Map

   For i  = 1 To KeyValuePairs.Length -2
   Dim sEntry() As String = Regex.Split("\=",KeyValuePairs(i).SubString2(0,KeyValuePairs(i).Length -1))
   Dim Key As String = sEntry(0).Trim
   Dim Value As String = sEntry(1).Trim
   If Value.Contains("""") Then
   If Value.Replace("""","'") = "''" Then Value = ""
   End If

   Return jMap
End Sub
It works, but I think it's not the best solution (I don't know why JSON.NextObject doesn't works fine).

Another issue: error2.png

Error occurred on line: 60 (frmbd)
Invalid update: invalid number of rows in section 0. The number of rows contained in an existing section after the update (295) must be equal to the number of rows contained in that section before the update (146), plus or minus the number of rows inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of rows moved into or out of that section (0 moved in, 0 moved out).
Stack Trace: (
CoreFoundation <redacted> + 150
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 0
Foundation <redacted> + 92
UIKit <redacted> + 8180
Bible.Show -[B4ITableView EndUpdates] + 46
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 300
Bible.Show +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1928
Bible.Show -[B4IShell runVoidMethod] + 210
Bible.Show -[B4IShell raiseEventImpl:method:args::] + 2002
Bible.Show -[B4IShellBI raiseEvent:event:params:] + 1316
Bible.Show +[B4IObjectWrapper raiseEvent:::] + 220
Bible.Show -[B4ITableViewDelgate tableView:didSelectRowAtIndexPath:] + 324
UIKit <redacted> + 918
UIKit <redacted> + 194
UIKit <redacted> + 308
UIKit <redacted> + 458
CoreFoundation <redacted> + 20
CoreFoundation <redacted> + 276
CoreFoundation <redacted> + 914
CoreFoundation CFRunLoopRunSpecific + 476
CoreFoundation CFRunLoopRunInMode + 106
GraphicsServices GSEventRunModal + 136
UIKit UIApplicationMain + 1440
Bible.Show main + 116
libdyld.dylib <redacted> + 2

I think you don't have to call BeginUpdates, when you clear the table, so this works fine:

Sub RefreshBD()
   Dim sKey As String = iStateManager.GetSetting("dictionary")
   ' get the text
   Dim sText As String = iStateManager.GetSetting("Bible Dictionary_" & sKey)
   Dim dMap As Map
   dMap = b4iMash.Json2Map(sText)
   sText = dMap.Get("text")
   pg.Title = "Bible Dictionary - " & sText

   b4iMash.ShowProgress("Loading bible dictionary...")
   Dim cur As ResultSet
   cur = b4iMash.Table_OpenRecordset(modBibleShow.SQLite, "select [Key],Text from BibleDictionary where Parent = '" & sKey & "' order by Text")
   Do While cur.NextRow
     Dim sKey As String: sKey = cur.GetString("Key")
     Dim sText As String: sText = cur.GetString("Text")
     b4iMash.AddSingleLine2(lstBD, sText, sKey)
End Sub
You have done the issue more than once.


Last edited:


Licensed User
Thanks JanPro:

I have looked at the images you have provided and also carefully at RefreshDB. RefreshDB first reads a record from iStateManager and passes that to Json2Map. I decided to look back at what was written originally to iStateManager. The record read by RefreshDB is first written by StoreBibleDictionary which has a method called Map2Json to process each record. I discovered that my records had quotes and thus needed to clear those first in my maps before converting them to json strings with Map2Json and reading them back with Json2Map. I have just rewritten Map2Json to remove the quotations without rewriting Json2Map. That should solve that. To update all the iStateManager saves, I have commented out all the "If iStateManager.GetSetting("load....." in all my methods to Store.... in Main.

Thanks for pointing this out. I will rerun the code and then also check Pendrush's proposal. Thanks for your eyes, they found something I missed.!
Last edited:


Licensed User
Lessons Learned So Far

LoadLayouts and TableView initialization should happen after showpage - updated all my code to reflect that. I'm using modules for pages
Removed all references to show and hide progress dialog, this for some reason does not show at all.
Decided to do away with json2map and map2json, they are not playing well with my app.
Removed all listview beginupdates and endupdates - they crash my app irrespective of what I do.

The issue now is refreshing a listview irrespective of which page im coming from after clicking a back button.

This has ensured the app doesnt crash anymore.