Skip to content

Commit e2086d4

Browse files
committed
[ADD] Optional id in CollectionViewContentView for newer xcode versions.
1 parent 32caa68 commit e2086d4

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Sources/Models/Views/ScrollViews/CollectionView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,9 @@ public struct CollectionViewCell: IBDecodable, ViewProtocol, IBIdentifiable, IBR
193193

194194
public struct CollectionViewContentView: IBDecodable, ViewProtocol {
195195

196+
/// - Note: Exists only in newer versions with `collectionViewCellContentView` key
197+
public let id: String?
198+
196199
public let elementClass: String = "UIView"
197200

198201
public let key: String?
@@ -245,6 +248,7 @@ public struct CollectionViewCell: IBDecodable, ViewProtocol, IBIdentifiable, IBR
245248
.nestedContainerIfPresent(of: .color, keys: ColorsCodingKeys.self)
246249

247250
return CollectionViewContentView(
251+
id: container.attributeIfPresent(of: .id),
248252
key: container.attributeIfPresent(of: .key),
249253
autoresizingMask: container.elementIfPresent(of: .autoresizingMask),
250254
clipsSubviews: container.attributeIfPresent(of: .clipsSubviews),

Tests/IBDecodableTests/Tests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ class Tests: XCTestCase {
387387
return
388388
}
389389
XCTAssertEqual(cell.contentView.key, "contentView")
390+
XCTAssertNil(cell.contentView.id)
390391
} catch {
391392
XCTFail("\(error) \(url)")
392393
}
@@ -405,6 +406,8 @@ class Tests: XCTestCase {
405406
return
406407
}
407408
XCTAssertEqual(cell.contentView.key, "contentView")
409+
XCTAssertNotNil(cell.contentView.id)
410+
XCTAssertEqual(cell.contentView.id, "YwU-He-qVe")
408411
} catch {
409412
XCTFail("\(error) \(url)")
410413
}

0 commit comments

Comments
 (0)