views:

33

answers:

2

my appdelegate is having the array book, this array is storing the many object like latitude and longitude coming from server. this object are containing the many latitude and longitude values coming from server.

values coming from the sever is store in the object file booknew and then this objects are stored in the array.

how can i read that values of latitude and longitude store in the object and that objects are store in the array.

A: 

Assuming the objects have accessors for these values, you'd just call those.

Chuck
A: 

If the data that comes from the server is an XML file it's easy. A simple way is to define the data as an array of objects, where each object is an NSDictionary. In each dictionary you can have values for the keys "lat" and "lng", as well as other information connected to each location. If this is how the data is arranged, you could access those values with something like this:

    for (id dict in book) {
    float latitude=[[dict objectForKey:@"lat"] floatValue];
    float longitude=[[dict objectForKey:@"lng"] floatValue];
    //code to use values here
}

If this is close to how the data can be arranged in the file, you can read it in with NSArray *book=[NSArray alloc] initWithContentsOfFile:filename] or similar.

If you want to be able to change the objects or the array, you must use an NSMutableArray array or NSMutableDictionary objects.

If the above is not doable (for example, if you have no influence over the file format), you will have to spend much more time writing custom code to read it in, parse it, and create objects yourself.

Henrik Erlandsson