Class: NSData
- Inherits:
-
Object
- Object
- NSData
- Defined in:
- lib/project/ns_data.rb
Overview
Shamelessly extracted from sugarcube github.com/rubymotion/sugarcube/blob/master/lib/cocoa/sugarcube-files/nsdata.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.read_from(path_or_url) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/project/ns_data.rb', line 7 def read_from(path_or_url) case path_or_url when NSURL self.dataWithContentsOfURL(path_or_url) when NSString self.dataWithContentsOfFile(path_or_url) else false end end |
Instance Method Details
#write_to(path_or_url, atomically = true) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/project/ns_data.rb', line 20 def write_to(path_or_url, atomically=true) case path_or_url when NSURL self.writeToURL(path_or_url, atomically: atomically) when NSString self.writeToFile(path_or_url, atomically: atomically) else false end end |