Skip to content

Commit

Permalink
Merge pull request #342 from art-divin/master
Browse files Browse the repository at this point in the history
Prefer DynamicMemberLookup over KVC
  • Loading branch information
djbe authored Aug 28, 2023
2 parents 4f222ac + ea58733 commit 1aeeced
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## 0.15.2

### Enhancements

- Prefer `DynamicMemberLookup` over KVC.
[##342](https://github.com/stencilproject/Stencil/pull/342)
[@art-divin](https://github.com/art-divin)

## 0.15.1

### Bug Fixes
Expand Down
10 changes: 5 additions & 5 deletions Sources/Stencil/Variable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,16 @@ public struct Variable: Equatable, Resolvable {
return resolve(bit: bit, collection: array)
} else if let string = context as? String {
return resolve(bit: bit, collection: string)
} else if let value = context as? DynamicMemberLookup {
return value[dynamicMember: bit]
} else if let object = context as? NSObject { // NSKeyValueCoding
#if os(Linux)
return nil
#else
#if canImport(ObjectiveC)
if object.responds(to: Selector(bit)) {
return object.value(forKey: bit)
}
#else
return nil
#endif
} else if let value = context as? DynamicMemberLookup {
return value[dynamicMember: bit]
} else if let value = context {
return Mirror(reflecting: value).getValue(for: bit)
}
Expand Down

0 comments on commit 1aeeced

Please sign in to comment.