Reordering Courses in a Queue | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/5429927-beginning-collection-views/lessons/30

@pasanpr, when I select more than 3 courses in section fatal error occurs:
***** Assertion failure in -[_UIDiffableDataSourceUpdate initWithIdentifiers:sectionIdentifiers:action:desinationIdentifier:relativePosition:destinationIsSection:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3901.4.2/_UIDiffableDataSource.m:1417**

2020-01-14 02:13:26.802124+0500 RWLibrary[12794:3641984] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: 'Fatal: supplied identifiers are not unique.'

Also both in your code and in mine lesson in queue list does not come first after pressing play button - it comes second.

Please help to find out what’s happening.

There is an issue with the way the gradient is done. Once the app is loaded and you press the Home button and then go back into the app, there seems to be some kind of cumulative effect.

BEFORE

(I was not allowed to post more than one image. The first one looks exactly as expected).

AFTER

I first noticed the effect when scrolling around but it is highly recreatable just leaving and going back in.

@andreysvx Apologies on the delay in getting back to you I somehow missed this! Were you able to solve this issue?

Thanks for uncovering this! The issue occurs because in GradientView.swift the gradient is being created and applied inside layoutSubviews(), which is called repeatedly when the app comes into foreground (or when the device is rotated).

The fix is fairly simple. On line 43 in GradientView.swift an instance of CAGradientLayer() is created. If you move this line of code outside the method to create a reference to the gradient the issue should be resolved!

1 Like

No problem) Unfortunately I have not managed to solve nor this neither other issues.=(

@pasanpr

I have faced this issue
’NSInternalInconsistencyException’, reason: 'Fatal: supplied identifiers are not unique.

After confirming Identifiable it is resolved

And resolved via below link:

Please guide me if it is wrong
 :slight_smile:

Your solution works so great job at that :+1: There’s most likely a missing identifier in the starter file that’s causing this issue. I will double check!

@andreysvx Do you still have issues with this?

Yes, still have issues with it =(

@pasanpr Can you please help with this when you get a chance? Thank you - much appreciated! :]

I guess url in Video may repeat -> identifier(we use 【url】in Video.swift) not unique

create an identifier using uuid solve this

//Video.swift
let identifier = UUID().uuidString

static func ==(lhs: Video, rhs: Video) -> Bool {
    return lhs.identifier == rhs.identifier
}
4 Likes

@ys_xs Thank you for sharing your solution - much appreciated!