Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

inverted

macrumors newbie
Original poster
Jul 3, 2009
4
0
hey



i am new in the iphone development. so i started with an own implementation of the wonderfull app "loopt" to get into the hole thing.

i have one problem with MKAnnotationViews, in the first step i put some AnnotationViews on the map. they represent friends of me.

in a second step i want so update their coordinates, cause my friends move around all the time.

i thought i could use the "dequeueReusableAnnotationViewWithIdentifier" - method for that. and just change or delete this annotation.

but even if i use different "reuseIdentifiers" for every MKAnnotationView, in the second step the Framework does not find an "old" AnnotationView, instead he always creates a new AnnotationView.

Code:
FriendAnnotationView* friendAnnotationView = (FriendAnnotationView*)[googleMap dequeueReusableAnnotationViewWithIdentifier:[friend username]];
     
if(nil == friendAnnotationView){
     friendAnnotationView = [[[FriendAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:[friend username]] autorelease];     
}


...


My test-method to refresh the coordinates of my friends :
Code:
- (IBAction) refresh{
     
     FriendsLocationDownloader* friendsDownloader = [[FriendsLocationDownloader alloc] init];
     NSArray* friends = [friendsDownloader downloadData];
     Friend* friend;
     for(int ndx = 0 ; ndx < friends.count ; ndx++){
          friend = [friends objectAtIndex:ndx];
     NSLog(@"refresh %@", [friend username]);
     [self addFriendAnnotationView:friend];
     [friend release];
     }
}

- (void)addFriendAnnotationView:(Friend*)friend{
     FriendAnnotation* annotation = [[[FriendAnnotation alloc] initWithFriend:friend] autorelease];
     [googleMap addAnnotation:annotation];      
}

has somebody done that befor ?

thank you very much !
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.