MacRuby - CLLocation Properties Not Accessible

Posted by Craig Williams on Stack Overflow See other posts from Stack Overflow or by Craig Williams
Published on 2010-04-30T23:00:13Z Indexed on 2010/04/30 23:07 UTC
Read the original article Hit count: 332

Filed under:

Anyone know why this works in Objective-C but not in MacRuby?

Objective-C Version:

CLLocation *loc = [[CLLocation alloc] initWithLatitude:38.0 longitude:-122.0];
NSLog(@"Lat: %.2f", loc.coordinate.latitude);
NSLog(@"Long: %.2f", loc.coordinate.longitude);
[loc release];
// Results:
// 2010-04-30 16:48:55.568 OCCoreLocationTest[70030:a0f] Lat: 38.00
// 2010-04-30 16:48:55.570 OCCoreLocationTest[70030:a0f] Long: -122.00

Here is the MacRuby version with results:

loc = CLLocation.alloc.initWithLatitude(38.0, longitude:-122.0)

puts loc.class
# => CLLocation
puts loc.description
# => <+38.00000000, -122.00000000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2010-04-30 16:37:47 -0600
puts loc.respond_to?(:coordinate) 
# => true
puts loc.coordinate.latitude
# => Error: unrecognized runtime type `{?=dd}' (TypeError)

© Stack Overflow or respective owner

Related posts about macruby