代码之家  ›  专栏  ›  技术社区  ›  Craig Williams

MacRuby-CLLocation属性不可访问

  •  1
  • Craig Williams  · 技术社区  · 16 年前

    MacRuby版本0.7->自2010-05-02起的最新版本 操作系统->10.6.3

    目标C版本:

    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
    

    以下是MacRuby版本的结果:

    framework 'corelocation'
    
    loc = CLLocation.alloc.initWithLatitude(38.0, longitude:-122.0)
    # => #<CLLocation:0x20004c4e0>
    
    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.horizontalAccuracy
    # => 0.0
    puts loc.verticalAccuracy
    # => -1.0
    puts loc.timestamp
    # => #<__NSCFDate:0x20005ff40>
    puts loc.coordinate
    # => #<Boxed:0x2000af7a0>
    puts loc.altitude
    # => 0.0
    puts loc.coordinate.longitude
    # => Error:in `<main>': undefined method `longitude' for #<Boxed:0x2000b7660> (NoMethodError)
    
    1 回复  |  直到 16 年前
        1
  •  0
  •   Craig Williams    16 年前

    我发现这已经有票了。 http://www.macruby.org/trac/ticket/641

    推荐文章