Bug? List.Sort by iOS 18

Filippo

Expert
Licensed User
Longtime User
Hi,

when using the “lst.sort” function, all my apps from iOS 18 onwards crashed.

Here is my code:

B4X:
Private Sub goShowSavedLaps
    Dim lst As List
    Dim strTmp As String
    lst.Initialize

    'Eine Liste mit alle Dokumenten erstellen
    lst = File.ListFiles(File.DirDocuments)
   
    If lst.Size > 0 Then
        lst.Sort(True)
        clvStoredRace.Clear
        For i = 0 To lst.Size -1
            strTmp = lst.get(i)
            If strTmp.EndsWith(ext) Then
                strTmp = strTmp.Replace(ext,"")
                clvStoredRace.Add(CreateLapListItem(strTmp, clvStoredRace.GetWidth, 50dip), lst.get(i))
            End If
        Next
    Else
        hd.ToastMessageShow("NoLapSaved"), True)
    End If
End Sub


Here is part of the crash:
Date/Time: 2024-09-18 12:47:50.823 +0200
OS Version: iPadOS 18.0 (22A3354)
Report Version: 104

Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000 at 0x0000000000000000
Crashed Thread: 0

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Swift.__SwiftDeferredNSArray sortUsingComparator:]: unrecognized selector sent to instance 0x3034c37c0'
 

OliverA

Expert
Licensed User
Longtime User
Tested with iOS 18:
I think the issue is with the list returned by ListFiles. Either the type of array returned has changed (from the underlying code) or the list now contains an object that is not a string or a number.
 

OliverA

Expert
Licensed User
Longtime User
Just saw @OliverA smart comment.
Yeah, but the read only list still sorts. It only bombs when adding / removing items from the list. I think the issue lies as stated in my comment above.
 

OliverA

Expert
Licensed User
Longtime User
I might modify the core library to make an internal copy.
I was in the middle of asking if this is a temp fix or if a fix will be issued (to keep code behavior the same on all platforms). But, of course, I was Ninja'd ?
 

Filippo

Expert
Licensed User
Longtime User
Something has changed in iOS 18 and File.ListFiles returns an immutable array right now. I'm keeping this open for now. Workaround is suggested above. I might modify the core library to make an internal copy.
Hi Erel,

should I wait until you have customized the Core-Library, or is it better to use this workaround so that I can update my apps?
 
Top