From: Chris S. <chr...@tr...> - 2008-01-10 17:58:01
|
Hello I am trying to make a new Custom OSX::NSFormatter. I have read the Objective-c documentation and I believe that the class below should work: Code: require 'osx/cocoa' class TotalTimeFormatter < OSX::NSFormatter def stringForObjectValue(anObject) OSX::NSLog("TotalTimeFormatter(stringForObjectValue): Passed Object - > %@ (%@)", anObject, anObject.class) return anObject.to_s(); end #ib_action :commitCurrentTimeRecord do |sender| def getObjectValue_forString_errorDescription(anObject, string, error) OSX ::NSLog ("TotalTimeFormatter(getObjectValue_forString_errorDescription): Passed Object -> %@ (%@)", anObject, anObject.class) return anObject.to_s(); end #ib_action :commitCurrentTimeRecord do |sender| def attributedStringForObjectValue_withDefaultAttributes(anObject, attributes) OSX ::NSLog ("TotalTimeFormatter (attributedStringForObjectValue_withDefaultAttributes): Passed Object - > %@ (%@) ", anObject, anObject.class) return anObject.to_s(); end end When running the app I get the following error in the log: 2008-01-10 12:43:51.117 TicTocRuby[1928:10b] TotalTimeFormatter (attributedStringForObjectValue_withDefaultAttributes): Passed Object - > 1146 (NSCFNumber) 2008-01-10 12:43:51.121 TicTocRuby[1928:10b] TotalTimeFormatter (attributedStringForObjectValue_withDefaultAttributes): Passed Object - > 1146 (NSCFNumber) 2008-01-10 12:43:51.126 TicTocRuby[1928:10b] *** -[NSCFString attribute:atIndex:longestEffectiveRange:inRange:]: unrecognized selector sent to instance 0xa0b5f8f4 /Users/chris/TicTocRuby/build/Debug/TicTocRuby.app/Contents/Resources/ rb_main.rb:22:in `NSApplicationMain': NSInvalidArgumentException - *** -[NSCFString attribute:atIndex:longestEffectiveRange:inRange:]: unrecognized selector sent to instance 0xa0b5f8f4 (OSX::OCException) from /Users/chris/TicTocRuby/build/Debug/TicTocRuby.app/Contents/ Resources/rb_main.rb:22 I have played around with this and it seems the only way I can have this class working correctly is to return a blank string using the following syntax, but this returns a blank string: return OSX::NSString.alloc.init If I try the following I get the same error: return OSX::NSString.alloc.initWithString("Hello World") I have looked over the documentation and I can't find any reference to that error. Any help would be much appreciated. Thanks In Advance!!! |