I can't speak to the encoding issues, but I can attest to crashing issues with incorrectly assuming the compatibility of NSPoint and CGPoint.
It depends what version of Mac OS you're on whether NSPoint can safely be cast as a CGPoint. In older versions of Mac OS, NSPoint used float for its members (32-bit) -- later, it switched to CGFloat (64-bit). There are functions in the Foundation framework that you can use, if you want to be safe: NSPointFromCGPoint and NSPointToCGPoint: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html#//apple_ref/c/func/NSPointFromCGPoint Also, check out the documentation here, on NSPoint, which gives the version history: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/uid/TP40003794 Best, -braxton On Mon, Dec 10, 2012 at 9:11 AM, Min Soo Kim <minsoo...@mac.com> wrote: > Hi David, > > I ran the following > > framework 'cocoa' > def initLabel(h) > @label = NSTextField.alloc.initWithFrame(CGRectMake(0,0,250, 45)) > @label.setStringValue(h) > @label.drawsBackground = false > @label.bezeled = false > @label.font = NSFont.fontWithName("Arial", size:45.0) > @label.editable = false > puts "class of label is #{@label.class}" > # width = > (@window.contentView.frameSize.width/2.0)-(@label.frameSize.width/2.0) > # height = > (@window.contentView.frameSize.height/2.0)-(@label.frameSize.height/2.0) > width=100.0 > height=200.0 > puts "width is #{width} heght is #{height}" > origin = NSMakePoint(width,height) > puts "class of origin is #{origin.class}" > @label.setFrameOrigin(origin) > puts @label.frame.origin > end > > initLabel("Hello") > > > I got the following output. > > class of label is NSTextField > width is 100.0 heght is 200.0 > class of origin is CGPoint > #<CGPoint:0x40013a340>class of origin is CGPoint > #<CGPoint:0x40013a340> > > It seem be to working for me. I think NSPoint and CGPoint can be mix used. > (Free ride) > I think the problem is in the `￯﾿ᄐ￯﾿ᄐ' whatever that is > > Min Soo Kim > > On Dec 10, 2012, at 3:37 PM, david kramf wrote: > > Hi Min, > This error message was produced by run environment and not by my code. I > don't do (knowingly ) anything with encoded text. Usually I get > comprehendible error messages when my code crashes. > Thanks, David > > On Dec 10, 2012, at 2:10 AM, Min Soo Kim wrote: > > Hello David, > > In your error message it says > > undefined method `￯﾿ᄐ￯﾿ᄐ' > > > Why are you getting `￯﾿ᄐ￯﾿ᄐ' instead of 'setFrameOrigin'? > Do you have some foreign encoded text somewhere? > > Min Soo Kim > > > On Dec 10, 2012, at 1:41 AM, david kramf wrote: > > Hello, > I am trying to create an NSPoint object so I can call setFrameOrigin but I > get in response a CGPoint object . When I pass the CGPoint to setFrameOrigin > , it crashes. How do I make NSMakePoint making an NSPoint object and not a > CGPoint object. > Thank you for your help, > David Kramf > > def initLabel(h) > @label = NSTextField.alloc.initWithFrame(CGRectMake(0,0,250, 45)) > @label.setStringValue(h) > @label.drawsBackground = false > @label.bezeled = false > @label.font = NSFont.fontWithName("Arial", size:45.0) > @label.editable = false > puts "class of label is #{@label.class}" > width = > (@window.contentView.frameSize.width/2.0)-(@label.frameSize.width/2.0) > height = > (@window.contentView.frameSize.height/2.0)-(@label.frameSize.height/2.0) > puts "width is #{width} heght is #{height}" > origin = NSMakePoint(width,height) > puts "class of origin is #{origin.class}" > @label.setFrameOrigin(origin) > end > > class of label is NSTextField > width is 75.0 heght is 77.5 > class of origin is CGPoint > 2012-12-09 18:33:13.525 two[3836:503] > /Users/davidkramf/Library/Developer/Xcode/DerivedData/two-gdovgltwrnzjfbfpizcbgrudvizf/Build/Products/Debug/two.app/Contents/Resources/MyController.rb:34:in > `initLabel': undefined method `￯﾿ᄐ￯﾿ᄐ' for > #<MyController:0x4011a6080> (NoMethodError) > from > /Users/davidkramf/Library/Developer/Xcode/DerivedData/two-gdovgltwrnzjfbfpizcbgrudvizf/Build/Products/Debug/two.app/Contents/Resources/MyController.rb:15:in > `initialize' > from /Users/davidkramf/Library/Developer > _______________________________________________ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo/macruby-devel > > > _______________________________________________ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo/macruby-devel > > > _______________________________________________ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo/macruby-devel > > > > _______________________________________________ > MacRuby-devel mailing list > MacRuby-devel@lists.macosforge.org > http://lists.macosforge.org/mailman/listinfo/macruby-devel > _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo/macruby-devel