Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3322504
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:11:23+00:00 2026-05-17T23:11:23+00:00

I am writing an iPad application (os 3.2) which uses MKMapKit to display moving

  • 0

I am writing an iPad application (os 3.2) which uses MKMapKit to display moving annotations on the map. Information is retrieved via XML from three different sources and collated together in my Annotation class and then displayed on the Map. This information is coming in every 5 seconds. I had this working fine for a few months with my annotations moving as required.

All the following code is a close approximation of the code (can’t post my companies exact code), and it was typed in line by line so it won’t compile.

My annotation code looked something like this:

@interface MyFunkyAnnotation : NSObject <MKAnnotation>
{
  CLLocationCoordinated2D coordinate;
  NSString *identifier;
  // Lots of other fields that can be displayed.
}
@property (nonatomic, assign) CLLocationCoordinate2D coordinate;
@property (nonatomic, retain) NSString *identifier;

// Lots of other properties as above.
-(void)updateFunkyAnnotationWithNewAnnotation:(MyFunkyAnnotation*)newFunky;

@end

Then in my implementation i had stuff like:

@implementation MyFunkyAnnotation

@synthesize coordinate;

-(void)updateFunkyAnnotationWithNewAnnotation:(MyFunkyAnnotation*)newFunky
{
  [self setCoordinate:[newFunky coordinate]];
  [self setIdentifier:[newFunky identifier]];
  // Lots more updating of various properties.
}
@end

This worked great, so I of course decided to redesign the whole thing and encapsulate alot of the information into other classes.

So now my code looks as follows:

@interface MyFunkyAnnotation: NSObject <MKAnnotation>
{
   SourceInfo_1  *source1;  // Contains its own coordinate property;
   SourceInfo_2  *source2;  // Contains its own coordinate property;
   SourceInfo_3  *source3;  // Contains its own coordinate property;
}
@property (nonatomic, retain) SourceInfo_1 *source1;
@property (nonatomic, retain) SourceInfo_2 *source2;
@property (nonatomic, retain) SourceInfo_3 *source3;

-(void)updateFunkyAnnotationWithNewAnnotation:(MyFunkyAnnotation*)newFunky;
-(CLLocationCoordinate2D)coordinate;

@end

The new implementation:

@implementation MyFunkyAnnotation

@synthesize source1, source2, source3;

-(CLLocationCoordinate2D)coordinate
{
   if ([source1 dataReliable] == YES)
   {
      return [source1 coordinate];
   }
   else if ([source2 dataReliable] == YES)
   {
      return [source2 coordinate];
   }
   else
   {
      return [source3 coordinate];
   }
 }

 -(void)updateFunkyAnnotationWithNewAnnotation:(MyFunkyAnnotation*)newFunky;
 {
    if ([newFunky source1] != nil)
    {
      [self setSource1:[newFunky source1];
    }
    if ([newFunky source2] != nil)
    {
      [self setSource2:[newFunky source2];
    }
    if ([newFunky source3] != nil)
    {
      [self setSource3:[newFunky source3];
    }
 }
 @end;

Running this new code resulted in the annotations being added in the original location but they never moved at all. I am updating the coordinates inside the source1, source2, source3 when I get the XML feeds.

So after a whole day of debugging and trying various things I got it to work. I then started to remove everything I had added in during the course of the day to get the following minimal changes to make it work and the results are quite strange:

The interface is unmodified.
In the implementation I added one method and added three other lines:

@implementation MyFunkyAnnotation

@synthesize source1, source2, source3;

-(void)setCoordinate:(CLLocationCoordinate2D)coordinate   //  <-- New method
{
  nil;
}

-(CLLocationCoordinate2D)coordinate
{
   if ([source1 dataReliable] == YES)
   {
      return [source1 coordinate];
   }
   else if ([source2 dataReliable] == YES)
   {
      return [source2 coordinate];
   }
   else
   {
      return [source3 coordinate];
   }
 }

 -(void)updateFunkyAnnotationWithNewAnnotation:(MyFunkyAnnotation*)newFunky;
 {
    if ([newFunky source1] != nil)
    {
      [self setSource1:[newFunky source1];
      [self setCoordinate:[[newFunky source1] coordinate]];  //  <--- New Line
    }
    if ([newFunky source2] != nil)
    {
      [self setSource2:[newFunky source2];
      [self setCoordinate:[[newFunky source2] coordinate]];  //  <--- New Line
    }
    if ([newFunky source3] != nil)
    {
      [self setSource3:[newFunky source3];
      [self setCoordinate:[[newFunky source3] coordinate]];  //  <--- New Line
   }
 }
 @end;

Can anyone explain why the need to call a method which doesn’t actually do anything. The “nil” was an NSLog statement so I know that it was being called. This makes absolutely no sense at all.

Any insight would be greatly appreciated.

Cheers,

Brett

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:11:23+00:00Added an answer on May 17, 2026 at 11:11 pm

    My guess is that this has something to do with not implementing the coordinate property. From the MKAnnotation Protocol documentation.

    An object that adopts this protocol must implement the coordinate property.

    Perhaps since you don’t have the coordinate property, you need the setCoordinate method in order for it work correctly handle the annotation.

    Have you tried adding

    @synthesize coordinate;
    

    to your your .m file? Assuming that you still have the property declaration in your header?

    You might have to specifically set the getter to your method in the property declaration. Something like

    @property (nonatomic, assign, getter=getCoordinate) CLLocationCoordinate2D coordinate;
    

    and then rename your coordinate method to getCoordinate.

    NOTE: it may be possible to avoid using the getter attribute and changing the coordinate accessor name but I haven’t tested that out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any reference about writing an application on iPad/iPhone to show HTML5 content
I'm writing an iPad application that mimics a flash website I built. The site
I'm thinking of writing an iPhone/iPad application to emulate a MIDI controller. I know
Are there any limitation in writing universal application for iPhone and iPad ? (or
Im writing an ipad application. So far what I have is a Delegate and
While writing an iPad application, I seem to be running into a lot of
Writing my first Linq application, and I'm trying to find the best way to
I've been plowing through basic shaders and whatnot for an application I'm writing, and
I've been writing my Universal application in portrait mode, and now after about 15
I am writing an iPad app that downloads a rather large .csv file and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.