0

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?

Community
  • 1
  • 1
Pavel Kaljunen
  • 1,291
  • 2
  • 26
  • 53

1 Answers1

0

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];
Martol1ni
  • 4,684
  • 2
  • 29
  • 39
  • This menas GetRack is not defined. Where have you defined it? – Martol1ni May 15 '12 at 16:47
  • how can I define it? sorry, I am a newbie. I just followed this solution http://stackoverflow.com/questions/10437578/xcode-annotation-from-property-list – Pavel Kaljunen May 15 '12 at 16:51
  • What are you even trying to accomplish!? What is GetRacks, and what is it supposed to do? The guy in that thread has a class called GetRack, that is why he can do it. – Martol1ni May 15 '12 at 16:54
  • I need to add Pins to my map from plist file. nothing more – Pavel Kaljunen May 15 '12 at 16:57
  • You need to learn some more objective-c before going further. The reason why NSString *string works, is because objective-c has a class called NSString. You can't just write whatever you want. If you want to write GetRack * racks, you have to make a class called GetRack. If you only want maps, read this: http://mayurbirari.wordpress.com/2011/02/07/how-to-access-mkmapkit-in-iphone/ - and then post questions that has relevance. Good luck! – Martol1ni May 15 '12 at 17:09
  • I've read it before, but I need an example with map and plist file. But thanks for spending time! – Pavel Kaljunen May 15 '12 at 17:15
  • Are you mixing the pList with something else? the plist is the information file of your app. Is the list initialized in your code? – Martol1ni May 15 '12 at 17:18
  • I mean a property list file that store a data – Pavel Kaljunen May 15 '12 at 17:27
  • Can you please show me the code? Or the list or whatever. I really don't understand what you are asking for. – Martol1ni May 15 '12 at 17:28
  • http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/PropertyLists/QuickStartPlist/QuickStartPlist.html#//apple_ref/doc/uid/10000048i-CH4-SW5 – Pavel Kaljunen May 15 '12 at 17:29
  • Follow that tutorial, that'll be enough... That is showing you how you can get the XML file importer to a NSArray. Then use that other guys method, and you'll be fine. – Martol1ni May 15 '12 at 17:47