Search code examples
iosxcodeannotationsproperty-listundeclared-identifier

Adding Annotation from Property List - use of undeclared identifier


I am trying to add an annotation from property list. I found a solution here:

Xcode Annotation from Property List

but it gives me an error "use of undeclared identifier "racks"" and "use of undeclared identifier "GetRacks"" here:

   // 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];
    }

Can anybody help me with this?


Solution

  • You do not initialize

    GetRacks racks
    

    when racks is not a pointer.

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

    is gonna work just fine!

    EDIT: change this:

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

    to this:

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