Sha256: 1c685c041810f98eaef848fef69c41d45922ee8a887ed0ddde34b191b3b73199

Contents?: true

Size: 559 Bytes

Versions: 46

Compression:

Stored size: 559 Bytes

Contents

class NSData

  # converts NSData into an NSString using any encoding, default is UTF8
  # @return [NSString]
  def nsstring(encoding=nil)
    if encoding
      return NSString.stringWithCString(self.bytes, encoding: encoding)
    else

      return NSString.stringWithUTF8String(self)
    end
  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

46 entries across 46 versions & 1 rubygems

Version Path
sugarcube-2.1.2 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-2.1.1 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-2.1.0 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-2.0.2 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-2.0.1 lib/cocoa/sugarcube-nsdata/nsdata.rb
sugarcube-2.0.0 lib/cocoa/sugarcube-nsdata/nsdata.rb