从属性列表添加注释 - 使用未声明的标识符

时间:2012-05-15 16:05:03

标签: ios xcode annotations property-list undeclared-identifier

我正在尝试从属性列表中添加注释。我在这里找到了一个解决方案:

  

Xcode Annotation from Property List

但是它给了我一个错误“使用未声明的标识符”机架“”和“使用未声明的标识符”GetRacks“”在这里:

   // Add annotations
    NSArray *bikePath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *bikeDocumentsDirectory = [bikePath objectAtIndex:0];
    NSString *path = [bikeDocumentsDirectory stringByAppendingPathComponent:@"data.plist"];

    NSDictionary* bikesDictionary = [[NSDictionary alloc] initWithContentsOfFile:path];
    GetRacks racks = [[GetRacks alloc] initWithDictionary:bikesDictionary];

    for(RackAnnotation *rackAnnotation in [racks getRacks])
    {
        [mapView addAnnotation:rackAnnotation];
    }

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

您没有初始化

GetRacks racks

当机架不是指针时。

GetRacks * racks = [[GetRacks alloc] initWithDictionary:bikesDictionary];

会好起来的!

编辑: 改变这个:

GetRacks racks = [[GetRacks alloc] initWithDictionary:bikesDictionary];

到此:

GetRacks * racks = [[GetRacks alloc] initWithDictionary:bikesDictionary];