Sha256: aa1920f2013f47ac15dbc27de2bdf13a6f01a30a4da1f4d73a2ff033003d12a1

Contents?: true

Size: 737 Bytes

Versions: 3

Compression:

Stored size: 737 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

  # @return [UIImage]
  def uiimage(scale=nil)
    if scale
      return UIImage.imageWithData(self, scale:scale)
    else
      return UIImage.imageWithData(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

3 entries across 3 versions & 1 rubygems

Version Path
sugarcube-0.20.9 lib/sugarcube/nsdata.rb
sugarcube-0.20.7 lib/sugarcube/nsdata.rb
sugarcube-0.20.6 lib/sugarcube/nsdata.rb