Permalink
Browse files

cause of an error '{_CMTime=qiIq}' (TypeError)

  • Loading branch information...
1 parent bd8bf63 commit bd99f4e60623ba1387466ea32634de3d9eedd07b @katsuyoshi committed Sep 27, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/sugarcube/nsdate.rb
View
@@ -16,7 +16,16 @@ def date
return [self.year, self.month, self.day]
end
- def time
+ # Cause of an error "unrecognized runtime type `{_CMTime=qiIq}' (TypeError)" is this method name
+ #
+ # I changed its name to time_. time_ method was works.
+ #
+ # (main)> t = Time.new
+ # => 2012-09-27 11:29:12 +0900
+ # (main)> t.time_
+ # => [11, 29, 12]
+# def time
+ def time_
return [self.hour, self.min, self.sec]
end

1 comment on commit bd99f4e

lrz commented on bd99f4e Sep 27, 2012

Very good catch! I suspect NSDate uses a private "time" method that returns a CMTime. Since private methods in Objective-C are still available in the runtime, RubyMotion tries to overwrite it here (and can't since it doesn't know about CMTime).

Using a different name for the method is definitely the way to go, as otherwise we would be monkey-patching the private method with new code that might break the NSDate internals.

Please sign in to comment.