Class: NSMutableAttributedString

Inherits:
Object
  • Object
show all
Defined in:
lib/hotcocoa/core_extensions/nsmutable_attributed_string.rb

Overview

HotCocoa extensions to the NSMutableAttributeString class.

Instance Method Summary collapse

Instance Method Details

#<<(s) ⇒ Object

Just like String#<<



7
8
9
10
11
12
13
14
# File 'lib/hotcocoa/core_extensions/nsmutable_attributed_string.rb', line 7

def << s
  case s
  when String
    mutableString.appendString s
  else
    appendAttributedString s
  end
end

#[]=(r, s) ⇒ Object

Replace an arbitrary range of an attributed string with another string.



21
22
23
24
25
26
27
28
# File 'lib/hotcocoa/core_extensions/nsmutable_attributed_string.rb', line 21

def []= r, s
  case s
  when String
    replaceCharactersInRange r.relative_to(length), withString: s
  else
    replaceCharactersInRange r.relative_to(length), withAttributedString: s
  end
end