Sha256: 351deed8a09ff07444440f16d4f59ac937452577e88fc7d508d44b8f8fa3851b

Contents?: true

Size: 486 Bytes

Versions: 8

Compression:

Stored size: 486 Bytes

Contents

class NSData

  # converts NSData into an NSString using any encoding, default is UTF8
  # @return [NSString]
  def nsstring(encoding=NSUTF8StringEncoding)
    return NSString.alloc.initWithData(self, encoding: encoding)
  end

  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

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sugarcube-4.0.0 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-3.5.0 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-3.4.2 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-3.4.1 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-3.4.0 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-3.3.7 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-3.3.6 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-3.3.5 lib/cocoa/sugarcube-nsdata/nsdata.rb