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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:06:15+00:00 2026-05-18T01:06:15+00:00

Thanks for the help in advance… this one has been killing me for the

  • 0

Thanks for the help in advance… this one has been killing me for the past couple of hours.

I am currently pulling in a JSON feed and storing it in a NSDictionary & NSArray. I’m trying to add an annotation for each item being pulled in (time, type, latitude, and longitude). So far, I can extract each value from the Array and have them all repeat with a “for” in the console (see code below).

How to I store these values as an annotation? Any help would be great.

Below is my failed attempt…


- (void)viewDidLoad {
  [super viewDidLoad];

 // Download JSON Feed
 NSDictionary *feed = [self downloadFeed];
 NSArray *streams = (NSArray *)[feed valueForKey:@"stream"];


 [mapView setMapType:MKMapTypeStandard];
 [mapView setZoomEnabled:YES];
 [mapView setScrollEnabled:YES];
 MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; 
 region.center.latitude = 29.719023;
 region.center.longitude = -114.157110;
 region.span.longitudeDelta = 0.01f;
 region.span.latitudeDelta = 0.01f;
 [mapView setRegion:region animated:YES]; 

 [mapView setDelegate:self];

 int Info;
 for (Info = 0; Info < streams.count; Info++) {
  NSDictionary *stream = (NSDictionary *)[streams objectAtIndex:Info];
  NSLog(@"Time: %@", [stream valueForKey:@"TheTime"]); 
  NSLog(@"Type: %@", [stream valueForKey:@"Type"]); 
  NSLog(@"Longitude: %@", [stream valueForKey:@"Longitude"]); 
  NSLog(@"Latitude: %@", [stream valueForKey:@"Latitude"]); 

  NSString *getLat = [[NSString alloc] initWithFormat: @"%@", [stream valueForKey:@"Latitude"]];
  NSString *getLong = [[NSString alloc] initWithFormat: @"%@", [stream valueForKey:@"Longitude"]];

  NSString *getCoord = [[NSString alloc] initWithFormat: @"{%@,%@}", getLat, getLong];
  getCoordinates = getCoord;


  DisplayMap *ann = [[DisplayMap alloc] init]; 
  ann.title = @"%@", [stream valueForKey:@"TheTime"];
  ann.subtitle = @"%@", [stream valueForKey:@"Type"]; 
  ann.coordinate = getCoordinates;

  [mapView addAnnotation:ann];

  }
}

Here is the code for DisplayMap

DisplayMap.h

#import <Foundation/Foundation.h>
#import <MapKit/MKAnnotation.h>


@interface DisplayMap : NSObject <MKAnnotation> {

    CLLocationCoordinate2D coordinate; 
    NSString *title; 
    NSString *subtitle;
    }

@property (nonatomic, copy) NSString *title; 
@property (nonatomic, copy) NSString *subtitle;

@property (nonatomic, readonly) CLLocationCoordinate2D coordinate; 


@end

And now DisplayMap.m

#import "DisplayMap.h"

@implementation DisplayMap

@synthesize coordinate;
@synthesize title;
@synthesize subtitle;


-(void)dealloc{
    [title release];
    [super dealloc];
    }

@end
  • 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-18T01:06:16+00:00Added an answer on May 18, 2026 at 1:06 am

    What type is getCoordinates? Whatever the case, its definitely not being initialized right.

    Assuming that your storing Latitude and Longitude as strings in your dictionary, this should do the trick.

    double lat = [[stream valueForKey:@"Latitude"] doubleValue];
    double lon = [[stream valueForKey:@"Longitude"] doubleValue];
    CLLocationCoordinate2D coord = { lat, lon };
    
    DisplayMap *ann = [[DisplayMap alloc] init]; 
    ann.title = [stream valueForKey:@"TheTime"];
    ann.subtitle = [stream valueForKey:@"Type"]; 
    ann.coordinate = coord;
    
    [mapView addAnnotation:ann];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks for any help in advance, I can't wrap my SQL skills around this
Thanks in advance for any help you can provide on this issue! I manage
First off, thanks in advance for your help. This issue is driving me nuts.
newbie here, so thanks in advance for help! I have a Wordpress site with
Thanks in advance for your help. I have a need within an application to
Thanks in advance for your help experts. I want to be able to copy
Hi thanks in advance for your help. I'm just getting started learning Python and
I need help in jquery. Thanks in advance. I am using autocomplete function of
I am using c# .net. Thanks in advance for any help. I have searched
Thanks for any help in advance. So, I'm storing songs in a filesystem with

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.