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 8354883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:41:42+00:00 2026-06-09T09:41:42+00:00

I have a NSObject class MyItem that holds several instance variables, among them a

  • 0

I have a NSObject class “MyItem” that holds several instance variables, among them a mapPoint declared in (MyMapPoint *)mapPoint. I use this MKMapPoint to add annotations to a MKMapView. The NSMutablearray “allItems” holds all items.

int all =[allItems count];
int i =0;    
for (i=0; i<all; i++) {

MyItem *p = [allItems objectAtIndex:i];
[mYView addAnnotation:[p mapPoint]];

This works perfect. I get a map full of pins where the items were registered. Also, I get a bubble when I push the pin, which gives title and subtitle. I have also managed to add a callout to the console.

NSLog (@"bubble is pushed");

which also works fine.

Problem: When I push the bubble, I want (to begin with) the console to log the full description of the actuall item the pin represents. Is there any sample code that traces back the to full MyItem? It seems like the pin has no recollection of its origin. All help, samplecode and links to samplecode will be heavilly appriciated.

  • 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-06-09T09:41:43+00:00Added an answer on June 9, 2026 at 9:41 am

    It sounds like you’ve got a separate type for your annotations (i.e. whatever is returned by the -mapPoint method). An easier way to deal with this is to implement the MKAnnotation protocol directly in your MyItem class. That way, instead of:

    [mYView addAnnotation:[p mapPoint]];
    

    you can just say:

    [mYView addAnnotation:p];
    

    By adopting MKAnnotation in your data object, you get direct access to the data you need when the user taps an annotation view.

    Another way to go, of course, is to stash a pointer back to your data object in you annotation. That can make more sense if your data objects are large, or if you have very many of them. It doesn’t even really have to be an actual object pointer — you just need to store some piece of information in your annotation that lets you later recover the data object. So, for example, you might include an identifier in your annotation. When the user taps the annotation view, you use the identifier to retrieve the associated data from your data store.

    Short answer: You’re responsible for connecting your annotations to your data; the framework doesn’t do it for you.

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

Sidebar

Related Questions

I have an instance of a NSObject class that is supposed to parse a
I have an object from a NSObject class that I call brand and has
I have a very basic data class that is subclassed from NSObject. I declare
Let's say I have a class declared as: @class SomeClass @interface SomeClass: NSObject {
I have a class (from NSObject ) that contains: NSString name int position float
I have a database model class that is a NSObject . I have a
I have an NSDictionary that I am passing to a NSObject Class where I
I have following simple class: @interface Article: NSObject { NSString *title; } @property (copy,
I have the following simple class definition: //mycommon.h @interface CurrentPath : NSObject @property (nonatomic,
I have a classes: BasicObject : NSObject AdvObject : BasicObject in other class i

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.