Class: SDL::Mac::ObjC::NSString

Inherits:
NSObject
  • Object
show all
Defined in:
lib/ruby-sdl-ffi/sdl/mac.rb

Instance Method Summary collapse

Methods inherited from NSObject

#inspect, nsclassname, #nsclassname, #release

Constructor Details

#initialize(str_or_ptr) ⇒ NSString



206
207
208
209
210
211
212
213
214
# File 'lib/ruby-sdl-ffi/sdl/mac.rb', line 206

def initialize( str_or_ptr )
  if str_or_ptr.is_a? String
    super( ObjC::NSClass("NSString").\
             msg_ptr("stringWithUTF8String:",
                     FFI.find_type(:string), str_or_ptr) )
  else
    super
  end
end

Instance Method Details

#to_sObject



216
217
218
219
# File 'lib/ruby-sdl-ffi/sdl/mac.rb', line 216

def to_s
  str = msg_ptr( "UTF8String" )
  (str.null?) ? "(NULL)" : str.read_string()
end