Class: NSError

Inherits:
Object show all
Defined in:
lib/cocoa/sugarcube-to_s/nserror.rb,
lib/ios/sugarcube-factories/nserror.rb,
lib/cocoa/sugarcube-localized/nserror.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.new(message = 'Error', options = {}) ⇒ Object


3
4
5
6
7
8
9
10
11
# File 'lib/ios/sugarcube-factories/nserror.rb', line 3

def self.new(message='Error', options={})
  domain = options[:domain] || 'Error'
  code = options[:code] || 0
  info = { NSLocalizedDescriptionKey => message }
  if options[:userInfo]
    info.merge! options[:userInfo]
  end
  NSError.alloc.initWithDomain(domain, code: code, userInfo: info)
end

Instance Method Details

#localizedObject Also known as: _


3
4
5
# File 'lib/cocoa/sugarcube-localized/nserror.rb', line 3

def localized
  localizedDescription
end

#to_sObject


3
4
5
6
7
8
# File 'lib/cocoa/sugarcube-to_s/nserror.rb', line 3

def to_s
  "#<#{self.class.to_s}:0x#{self.object_id.to_s(16)}, "+
    "description=#{self.localizedDescription.inspect}, code=#{code}, "+
    "domain=#{domain.inspect}, userInfo=#{userInfo.inspect}"+
   ">"
end