0

I'm trying to reload some cells of my collectionView using this code,

var indexPathsToReload = [NSIndexPath]()
        for var i in 0..<Data.NearByList.count {
            indexPathsToReload.append(NSIndexPath(forItem: i, inSection: 0))
        }

        collview.reloadItemsAtIndexPaths(indexPathsToReload)

it works fine when testing in Xcode's Simulator , but when I build it on my iOS device i have this error `

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSStackBlock__ _FBSDisplayDidPossiblyConnect:withScene:]: unrecognized selector sent to instance 0x41ca6c' * First throw call stack: (0x2799386b 0x39092dff 0x27999035 0x27996c8f 0x278c62b8 0x2c2387d3 0x2c238379 0x2bb09dc3 0x2c241e7b 0x2bc82b45 0x2c2435fd 0x2bab3abd 0x2c242e25 0x2c2413fd 0x2bc7ea1d 0x199654 0x19971c 0x2babd5e3 0x2babdb63 0x2bddda0d 0x2bee9e19 0x2bde0e7d 0x2bbcddff 0x2bbcdc35 0x2bbcd7af 0x2bbcd34b 0x2badea99 0x2bade993 0x2b3741a7 0x1483dab 0x1488829 0x27956595 0x27954a8f 0x278a71e9 0x278a6fdd 0x30b4baf9 0x2bb0c18d 0x1b86dc 0x397bd873) libc++abi.dylib: terminating with uncaught exception of type NSException `

Updated here is main exception

`

CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:]:
->  0x27998f78 <+0>:   push   {r4, r5, r6, r7, lr}
    0x27998f7a <+2>:   add    r7, sp, #0xc
    0x27998f7c <+4>:   sub    sp, #0xc
    0x27998f7e <+6>:   mov    r5, r0
    0x27998f80 <+8>:   movw   r0, #0xb09a
    0x27998f84 <+12>:  movt   r0, #0x13f7
    0x27998f88 <+16>:  mov    r4, r2
    0x27998f8a <+18>:  add    r0, pc
    0x27998f8c <+20>:  ldr    r1, [r0]
    0x27998f8e <+22>:  mov    r0, r5
    0x27998f90 <+24>:  blx    0x279ebf9c                ; symbol stub for: __destroy_helper_block_472
    0x27998f94 <+28>:  mov    r1, r5
    0x27998f96 <+30>:  mov    r2, r4
    0x27998f98 <+32>:  bl     0x279996c4                ; __CFFullMethodName
    0x27998f9c <+36>:  movw   r6, #0x791c
    0x27998fa0 <+40>:  mov    r4, r0
    0x27998fa2 <+42>:  movt   r6, #0x1223
    0x27998fa6 <+46>:  movs   r0, #0x3
    0x27998fa8 <+48>:  add    r6, pc
    0x27998faa <+50>:  mov    r2, r4
    0x27998fac <+52>:  mov    r1, r6
    0x27998fae <+54>:  mov    r3, r5
    0x27998fb0 <+56>:  bl     0x2797cfb0                ; CFLog
    0x27998fb4 <+60>:  movw   r0, #0xc09e
    0x27998fb8 <+64>:  movs   r1, #0x0
    0x27998fba <+66>:  movt   r0, #0x1220
    0x27998fbe <+70>:  mov    r2, r6
    0x27998fc0 <+72>:  str    r5, [sp]
    0x27998fc2 <+74>:  add    r0, pc
    0x27998fc4 <+76>:  mov    r3, r4
    0x27998fc6 <+78>:  ldr    r0, [r0]
    0x27998fc8 <+80>:  movs   r5, #0x0
    0x27998fca <+82>:  ldr    r0, [r0]
    0x27998fcc <+84>:  bl     0x278b5b60                ; CFStringCreateWithFormat
    0x27998fd0 <+88>:  bl     0x278ace04                ; CFMakeCollectable
    0x27998fd4 <+92>:  mov    r4, r0
    0x27998fd6 <+94>:  mov    r8, r8
    0x27998fd8 <+96>:  mov    r8, r8
    0x27998fda <+98>:  movw   r0, #0xc0ca
    0x27998fde <+102>: movt   r0, #0x1220
    0x27998fe2 <+106>: add    r0, pc
    0x27998fe4 <+108>: ldr    r0, [r0]
    0x27998fe6 <+110>: ldrb   r0, [r0]
    0x27998fe8 <+112>: cbz    r0, 0x27998ffc            ; <+132>
    0x27998fea <+114>: movs   r0, #0x3
    0x27998fec <+116>: mov    r1, r4
    0x27998fee <+118>: str    r5, [sp]
    0x27998ff0 <+120>: movs   r2, #0x0
    0x27998ff2 <+122>: movs   r3, #0x0
    0x27998ff4 <+124>: str    r5, [sp, #0x4]
    0x27998ff6 <+126>: str    r5, [sp, #0x8]
    0x27998ff8 <+128>: bl     0x27957b38                ; __CFRecordAllocationEvent
    0x27998ffc <+132>: mov    r0, r4
    0x27998ffe <+134>: blx    0x279ebd5c                ; symbol stub for: ___CFPreferencesNotifyOfImpendingUserDeletion_block_invoke
    0x27999002 <+138>: mov    r3, r0
    0x27999004 <+140>: movw   r0, #0xc2d8
    0x27999008 <+144>: movt   r0, #0x1220
    0x2799900c <+148>: movw   r1, #0xb1ac
    0x27999010 <+152>: add    r0, pc
    0x27999012 <+154>: movt   r1, #0x13f7
    0x27999016 <+158>: movw   r2, #0xbbd0
    0x2799901a <+162>: ldr    r6, [r0]
    0x2799901c <+164>: add    r1, pc
    0x2799901e <+166>: movt   r2, #0x13f7
    0x27999022 <+170>: ldr    r1, [r1]
    0x27999024 <+172>: add    r2, pc
    0x27999026 <+174>: str    r5, [sp]
    0x27999028 <+176>: ldr    r0, [r2]
    0x2799902a <+178>: ldr    r2, [r6]
    0x2799902c <+180>: blx    0x279ebf9c                ; symbol stub for: __destroy_helper_block_472
    0x27999030 <+184>: blx    0x279ebf1c                ; symbol stub for: __NSOrderedSetEquateKeys

`////UPDATED here is my colelctionview:cellforItemsatIndexPaths

func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
        // get a reference to our storyboard cell
        let cell = collectionView.dequeueReusableCellWithReuseIdentifier(self.reuseIdentifier, forIndexPath: indexPath) as! CustomCollectionCell

        cell.UserID = Data.NearByList[Int(indexPath.item.value)].UserID

        cell.personImage.image=Data.UserIDImageMap[cell.UserID]
        cell.personImage.layer.cornerRadius=(cell.bounds.height-10) / 2.0

        if Data.NearByList[Int(indexPath.item.value)].Distance < 0.1 {
                cell.Location.text=String("0.0")+"\nkm"
        }
        else
        {
            cell.Location.text=String(Helpers.roundNumber(Data.NearByList[Int(indexPath.item.value)].Distance))+"\nkm"
        }




        if  Data.NearByList[Int(indexPath.item.value)].Selected == 1
        {
            cell.personImage.layer.borderColor = UIColor(rgb: 0x98cc00).CGColor
            cell.personImage.alpha=1
            cell.Location.textColor=UIColor.whiteColor()
            cell.LocationImage.image=UIImage(named: "SelectedPin.png")
        }
        else
        {
            cell.personImage.layer.borderColor = UIColor.grayColor().CGColor
            cell.personImage.alpha=0.5
            cell.Location.textColor=UIColor.grayColor()
            cell.LocationImage.image=UIImage(named: "UnSelectedPin.png")
        }



        cell.personImage.layer.borderWidth=3
        cell.personImage.layer.masksToBounds=true




        return cell
    }

I dowload Images asyncronously and after every downloaded image raise the event with SwiftEventBus and reload collectionView

SwiftEventBus.onMainThread(self, name: "ReloadHomePage") { result in
            let id=result.object as! Int

            self.collview.reloadData()

           // self.collview.reloadItemsAtIndexPaths([NSIndexPath(forItem: id, inSection: 0)])


        }

but some of cells not appears like circle and i have to scrolling to make them right.I want to reload at index paths for this and this error appears

Narek Simonyan
  • 572
  • 1
  • 7
  • 18

1 Answers1

0

Can you please post more code? what is the type of collview? Are you seeing the selector exception during the above code? If yes, which is the selector name in error? I suspect the selector issue is unrelated to the above code.

Will update this answer if i get more details :)