MihaelIsaev / MihaelIsaev/UIKitPlus
About ClosedRange's extension and AttributedString
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 628
- Forks
- 36
- PR merge metrics
- No merged PRs in 30d
Description
As the code says in ClosedRange+NSRange:
var nsRange: NSRange { return .init(location: first ?? 0, length: last ?? 0) }
and it's used in AttributedString.swift this function
@discardableResult
func addAttribute(_ attr: NSAttributedString.Key, _ value: Any, at range: ClosedRange<Int>? = nil) -> AttributedString {
// TODO: check range
let range = range ?? 0..._attributedString.length
_attributedString.addAttribute(attr, value: value, range: range.nsRange)
_updateHandler?(_attributedString)
return self
}
I'm a bit confuse for how I configured the 'range' such as 23 to 24 because I can't pass 23...24 which means it start at 23 but length is 24 or 23...1 which the first should be smaller or equal the last. I need your help.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ClosedRange+NSRange and the addAttribute function in AttributedString.swift. Reproduce the reported 23...24 case and inspect how the ClosedRange is converted before being passed to NSAttributedString. Done means the intended range behavior is clarified and the conversion or its usage is corrected accordingly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100