0xLet / SwiftUIKit

📱 UIKit code that is fun to write
https://0xlet.github.io/SwiftUIKit/
MIT License
74 stars 6 forks source link

Issue with multiple Attributed Strings #71

Closed 0xLeif closed 4 years ago

0xLeif commented 4 years ago

Code:

Label(civ.name)
                .apply(attributes: StringAttributes(for: .foregroundColor, value: UIColor.red), range: 0 ... 2)
                .apply(attributes: StringAttributes(for: .foregroundColor, value: UIColor.blue), range: 3 ... 4)

BT:

2019-12-14 20:43:12.457169-0600 AOEII[68802:1815366] *** Terminating app due to uncaught exception 'NSRangeException', reason: 'NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff23b98bde __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00007fff503b5b20 objc_exception_throw + 48
    2   Foundation                          0x00007fff25727f53 -[NSMutableRLEArray deleteObjectsInRange:] + 0
    3   Foundation                          0x00007fff25726e79 -[NSConcreteMutableAttributedString setAttributes:range:] + 99
    4   AOEII                               0x0000000101409e12 $sSo25NSMutableAttributedStringC10SwiftUIKitE3set10attributes5rangeABXDSDySo012NSAttributedC3KeyaypG_SNySiGtF + 162
    5   AOEII                               0x00000001014233c4 $s10SwiftUIKit5LabelC5apply10attributes5rangeACXDSDySo21NSAttributedStringKeyaypG_SNySiGtF + 788
    6   AOEII                               0x00000001013debb0 $s5AOEII18BaseViewControllerC9navButton33_3464AA06B180A1E8A8D855665E1F6A95LL15forCivilizationSo6UIViewCAA0Q0V_tFAHyXEfU0_ + 688
    7   AOEII                               0x00000001014184ce $s10SwiftUIKit6ButtonC_8forEvent_ACyyc_So15UIControlEventsVSo6UIViewCyXEtcfcAHyXEfU_ + 46
    8   AOEII                               0x000000010140ad82 $sSo6UIViewC10SwiftUIKitE5embed11withPadding_ABXDSf_AByXEtF + 66
    9   AOEII                               0x00000001014183d7 $s10SwiftUIKit6ButtonC_8forEvent_ACyyc_So15UIControlEventsVSo6UIViewCyXEtcfc + 487
    10  AOEII                               0x000000010142b8c9 $s10SwiftUIKit9NavButtonC_11destination5style_ACyycSg_So16UIViewControllerCAA8NavigateC15NavigationStyleOSo0G0CyXEtcfc + 489
    11  AOEII                               0x000000010142b6d3 $s10SwiftUIKit9NavButtonC_11destination5style_ACyycSg_So16UIViewControllerCAA8NavigateC15NavigationStyleOSo0G0CyXEtcfC + 99
    12  AOEII                               0x00000001013de5ef $s5AOEII18BaseViewControllerC9navButton33_3464AA06B180A1E8A8D855665E1F6A95LL15forCivilizationSo6UIViewCAA0Q0V_tF + 559
    13  AOEII                               0x00000001013df93a $s5AOEII18BaseViewControllerC06reloadC033_3464AA06B180A1E8A8D855665E1F6A95LLyyFyycfU_So6UIViewCyXEfU_AGyXEfU_SayAGGyXEfU_AgA12CivilizationVXEfU_ + 42
    14  AOEII                               0x00000001013df98b $s5AOEII12CivilizationVSo6UIViewCs5Error_pIggozo_AcEsAF_pIegnrzo_TR + 59
    15  AOEII                               0x00000001013e0764 $s5AOEII12CivilizationVSo6UIViewCs5Error_pIggozo_AcEsAF_pIegnrzo_TRTA + 20
    16  libswiftCore.dylib                  0x00007fff5087b3df $sSlsE3mapySayqd__Gqd__7ElementQzKXEKlF + 751
    17  AOEII                               0x00000001013df8a0 $s5AOEII18BaseViewControllerC06reloadC033_3464AA06B180A1E8A8D855665E1F6A95LLyyFyycfU_So6UIViewCyXEfU_AGyXEfU_SayAGGyXEfU_ + 208
    18  AOEII                               0x0000000101432c0b $s10SwiftUIKit5TableC17defaultCellHeight09estimatedeF0_ACSfSg_AFSaySo6UIViewCGyXEtcfc + 811
    19  AOEII                               0x0000000101432887 $s10SwiftUIKit5TableC17defaultCellHeight09estimatedeF0_ACSfSg_AFSaySo6UIViewCGyXEtcfC + 135
    20  AOEII                               0x00000001013df7b1 $s5AOEII18BaseViewControllerC06reloadC033_3464AA06B180A1E8A8D855665E1F6A95LLyyFyycfU_So6UIViewCyXEfU_AGyXEfU_ + 161
    21  AOEII                               0x00000001014056b1 $s10SwiftUIKit12SafeAreaViewCyACSo6UIViewCyXEcfc + 49
    22  AOEII                               0x000000010140561a $s10SwiftUIKit12SafeAreaViewCyACSo6UIViewCyXEcfC + 58
    23  AOEII                               0x00000001013df6eb $s5AOEII18BaseViewControllerC06reloadC033_3464AA06B180A1E8A8D855665E1F6A95LLyyFyycfU_So6UIViewCyXEfU_ + 91
    24  AOEII                               0x000000010140ad82 $sSo6UIViewC10SwiftUIKitE5embed11withPadding_ABXDSf_AByXEtF + 66
    25  AOEII                               0x00000001013df65f $s5AOEII18BaseViewControllerC06reloadC033_3464AA06B180A1E8A8D855665E1F6A95LLyyFyycfU_ + 351
    26  AOEII                               0x00000001013dfa7d $sIeg_IeyB_TR + 45
    27  libdispatch.dylib                   0x0000000101809df0 _dispatch_call_block_and_release + 12
    28  libdispatch.dylib                   0x000000010180ad64 _dispatch_client_callout + 8
    29  libdispatch.dylib                   0x0000000101818e1c _dispatch_main_queue_callback_4CF + 1500
    30  CoreFoundation                      0x00007fff23afb699 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    31  CoreFoundation                      0x00007fff23af62f9 __CFRunLoopRun + 2329
    32  CoreFoundation                      0x00007fff23af56b6 CFRunLoopRunSpecific + 438
    33  GraphicsServices                    0x00007fff3815cbb0 GSEventRunModal + 65
    34  UIKitCore                           0x00007fff47162a67 UIApplicationMain + 1621
    35  AOEII                               0x00000001013f0f6b main + 75
    36  libdyld.dylib                       0x00007fff5123bcf5 start + 1
    37  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
0xLeif commented 4 years ago

https://github.com/zmeriksen/AOEII

0xLeif commented 4 years ago

'NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds'

Not an issue for SwiftUIKit