Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ x.y.z Release notes (yyyy-MM-dd)
* None.

### Fixed
* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-cocoa/issues/????), since v?.?.?)
* None.
* Fix `RLMCollectionIterator` where `RLMCollectionIterator` contents were not RLMObject.
This is for users using the optional `RLMSupport.swift` file.

<!-- ### Breaking Changes - ONLY INCLUDE FOR NEW MAJOR version -->

Expand Down
4 changes: 2 additions & 2 deletions Realm/Swift/RLMSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public struct RLMCollectionIterator: IteratorProtocol {
iteratorBase = NSFastEnumerationIterator(collection)
}

public mutating func next() -> RLMObject? {
return iteratorBase.next() as! RLMObject?
public mutating func next() -> AnyObject? {
return iteratorBase.next() as AnyObject?
}
}

Expand Down
23 changes: 23 additions & 0 deletions RealmSwift/Tests/ObjectiveCSupportTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,27 @@ class ObjectiveCSupportTests: TestCase {
}
expected.forEach { testObjCSupport($0.0, value: $0.1) }
}

#if !SWIFT_PACKAGE
func testArraySupport() {
let list = List<SwiftObject>()
let obj = SwiftObject()
list.append(obj)
obj.doubleCol = 42.42
let rlmArray = ObjectiveCSupport.convert(object: list)
XCTAssert(rlmArray.isKind(of: RLMArray<AnyObject>.self))
for object in rlmArray {
XCTAssertEqual(obj.doubleCol, object.value(forKey: "doubleCol") as? Double)
}

let primitiveList = List<Double>()
let double = 42.42
primitiveList.append(double)
let primitiveRLMArray = ObjectiveCSupport.convert(object: primitiveList)
XCTAssert(primitiveRLMArray.isKind(of: RLMArray<AnyObject>.self))
for object in primitiveRLMArray {
XCTAssertEqual(double, object as? Double)
}
}
#endif
}