Sizeof with ios objects - ParkinT/RubyMotion_Life GitHub Wiki

def sizeof(type)
  size_ptr = Pointer.new(:uint)
  align_ptr = Pointer.new(:uint)
  NSGetSizeAndAlignment(type, size_ptr, align_ptr)
  size_ptr[0]
end
# sample code
sizeof(CTParagraphStyleSetting.type) # => 12
sizeof(CGRect.type) # => 16
sizeof(:float) # => 4