Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: setAttribute and addAttribute overrides w/o range #48

Open
thejeff77 opened this issue Apr 18, 2020 · 1 comment
Open

Comments

@thejeff77
Copy link

Would be pretty sweet to have methods that set attributes on the whole range. Override existing methods without a range param will set attributes for the whole range.

    func addAttributes(_ attributes: [Attribute])
    func addAttributes(_ attributes: [Attribute])
    func setAttributes(_ attributes: [Attribute])
    func setAttributes(_ attributes: [Attribute])
@thejeff77
Copy link
Author

thejeff77 commented Apr 18, 2020

Quick code for getting whole range:

let wholeRange = (text.string as NSString).range(of: text.string)

Would also make a good var extension.

eg:

extension NSAttributedString { // (and mutable attributed string) 
  var range: Range {
    get {
      return (self.string as NSString).range(of: self.string)
    }
  }

  func range(of string: String) {
    return (self.string as NSString).range(of: string)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant