views:

53

answers:

2

I got my application working Awhile back, but after completely and accidentally deleting it, I have tried to create it from square one. unfortunately my rewritten program is a bit cranky; does anyone see or know the possible sources of error? Also, my if statements are acting up.

-(void)loadAnnotations
{
    CLLocationCoordinate2D workingCoordinate;
    iProspectLiteAppDelegate *appDelegate = (iProspectLiteAppDelegate *)[[UIApplication sharedApplication] delegate];
    NSMutableArray *mines =[[NSMutableArray alloc] initWithArray:(NSMutableArray *) appDelegate.mines];
    BOOL gold = [[NSUserDefaults standardUserDefaults] boolForKey:@"goldControl"];
    BOOL silver = [[NSUserDefaults standardUserDefaults] boolForKey:@"silverControl"];
    BOOL copper = [[NSUserDefaults standardUserDefaults] boolForKey:@"copperControl"];
    for(id mine in mines)
    {
    NSLog(@"in the loop");
    workingCoordinate.latitude = [[mine latitudeInitial] doubleValue];
    workingCoordinate.longitude = [[mine longitudeInitial] doubleValue];
    iProspectLiteAnnotation *tempMine = [[iProspectLiteAnnotation alloc] initWithCoordinate:workingCoordinate];
    [tempMine setTite:[mine mineName]];

    if ([[mine commodity] isEqualToString:@"Gold"] && [gold == YES])
    {
        [tempMine setAnnotationType:iProspectLiteAnnotationTypeGold];
        [mapView addAnnotation:tempMine];
    }
    if([[mine commodity] isEqualToString:@"Silver"] && [silver == YES])
    {
        [tempMine setAnnotationType:iProspectLiteAnnotationTypeSilver];
    }
    if([[mine commodity] isEqualToString:@"Copper"] && [copper == YES])
    {
        [tempMine setAnnotationType:iProspectLiteAnnotationTypeCopper];
    }
}
[mines dealloc];
}

where the workingCoordinate.latitude = [[mine latitudeInitial] doubleValue], as well as the longitude, and [mine mineName],it says " No '-latitudeInitiallongitudeInitial' method found" or the mineName/LongitudeInitial. also, it complains about : before ] at all the if statement lines. I don't see any errors, do you?

+1  A: 

You are using an iterator that is giving you objects of type id - calling a method on those will often confuse a compiler. Are you able to cast them to a known type?

Like for(MineType* mine in mines)?

And

[tempMine setTite:[mine mineName]];

Is that a typo? My guess is you would be calling that method setTitle.

Adam Eberbach
Ok the setTite was a typo. that much I fixed. And your solution worked!
kevin Mendoza
A: 

i think changing the object type of mine object in the for loop to whatever custom class you have with latitudeInitial, longitudeInitial, mineName properties/methods should solve this.

lukya
yeap that did it too.
kevin Mendoza