Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
5020
NSRangeException on viewDidAppear
posted

This may be a minor issue... but it looks like a race condition. I can reliably reproduce the following NSRangeException.

2014-07-01 08:20:02.324 XXXXXX 2[7302:60b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'

Copy/paste from the debugger.

0x1e1698:  blt    0x1e170a                  ; -[IGFlowLayoutView insertItemAtIndex:] + 398 at IGFlowLayoutView.m:877

0x1e169a:  mov    r0, r8

0x1e169c:  mov    r1, r6

0x1e169e:  blx    0x21ad2c                  ; symbol stub for: objc_msgSend

0x1e16a2:  ldr    r1, [sp, #0x18]

0x1e16a4:  adds   r2, r0, #0x1

0x1e16a6:  mov    r0, r8

0x1e16a8:  blx    0x21ad2c                  ; symbol stub for: objc_msgSend

0x1e16ac:  ldr    r1, [sp, #0x1c]

0x1e16ae:  mov    r0, r5

0x1e16b0:  mov    r4, r0

0x1e16b2:  ldr    r5, [r0, r1]

0x1e16b4:  mov    r0, r8

0x1e16b6:  mov    r1, r6

0x1e16b8:  blx    0x21ad2c                  ; symbol stub for: objc_msgSend

0x1e16bc:  ldr    r1, [sp, #0x20]

0x1e16be:  mov    r2, r0

0x1e16c0:  mov    r0, r5

0x1e16c2:  blx    0x21ad2c                  ; symbol stub for: objc_msgSend

0x1e16c6:  mov    r7, r7

0x1e16c8:  blx    0x21ad4c                  ; symbol stub for: objc_retainAutoreleasedReturnValue

0x1e16cc:  mov    r11, r0

0x1e16ce:  add    r0, sp, #0x4c

0x1e16d0:  cmp.w  r11, #0x0

0x1e16d4:  bne    0x1e16e4                  ; -[IGFlowLayoutView insertItemAtIndex:] + 360 at IGFlowLayoutView.m:875

0x1e16d6:  vst1.32 {d8, d9}, [r0]

0x1e16da:  movs   r0, #0x0

0x1e16dc:  movs   r1, #0x0

0x1e16de:  movs   r3, #0x0

0x1e16e0:  movs   r2, #0x0

0x1e16e2:  b      0x1e16f4                  ; -[IGFlowLayoutView insertItemAtIndex:] + 376 at IGFlowLayoutView.m:875

0x1e16e4:  ldr    r2, [sp, #0x10]

0x1e16e6:  mov    r1, r11

0x1e16e8:  blx    0x21ad38                  ; symbol stub for: objc_msgSend_stret

0x1e16ec:  ldr    r2, [sp, #0x4c]

0x1e16ee:  ldr    r3, [sp, #0x50]

0x1e16f0:  ldr    r1, [sp, #0x54]

0x1e16f2:  ldr    r0, [sp, #0x58]


This happens when these conditions are all true: Pop a VC that is saving a new core data object.  The previous flowView loads (herein referred to as parentVC), and it itself is "powered" by a FRC insofar is the FRCs delegate methods update the flowView with insert/delete/etc.

This all works and isn't enough to raise the exception. The exception is raised if I place this in the parentVC.

-(void)viewWillAppear:(BOOL)animated

{

    [self.flowView updateData];

}

This is what kills it.  I think the flowView is already being updated... and updateData is not playing nice with the insert method.  I am calling all insert/update/delete flow view methods via dispatch_async via the FRC delegate.