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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:04:55+00:00 2026-06-04T01:04:55+00:00

Im trying to add to a mutable array and can not figure this out.

  • 0

Im trying to add to a mutable array and can not figure this out. Throws error for incompatable data types double to id. question is how do i convert distance and store it in my array.

for (int i = 0; i < _getAllLocations.count; i++) {

uscInfo *entity = [_getAllLocations objectAtIndex:i];
NSNumber *numlat=[[NSNumber alloc] initWithDouble:[entity.Latitude doubleValue]];
NSNumber *numlon=[[NSNumber alloc] initWithDouble:[entity.Longitude doubleValue]];
NSLog(@"%d",[_getAllLocations count]);
la=[numlat doubleValue];
lo=[numlon doubleValue];
CLLocation *currentLocation =  [[CLLocationalloc]initWithLatitude:lalongitude:lo];////here put your destination point

//NSLog(@"New Location:%@", newLocation);
CLLocationDistance distance = [newLocation distanceFromLocation:currentLocation];
NSLog(@"%@ (%@) %4.0f km from current location",entity.EntityNo, entity.EntityName, distance);
NSLog(@"%@",currentLocation);

I am trying to store “distance” in my array “locationDistance”

thanks for any help, I am still new to iOS as well as programming in general.

  • 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-04T01:04:56+00:00Added an answer on June 4, 2026 at 1:04 am

    (You really should include the code that’s not working – in this case the actual addObject: code.)

    But I can tell you that the problem is you are likely trying to add a naked CLLocationDistance to the array, which won’t work as it’s not an object. It’s typedef‘d as a double so you need to wrap it using, e.g., [NSNumber numberWithDouble:distance].

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

Sidebar

Related Questions

I'm trying to simply add objects to a mutable array but they WILL NOT
I'm trying to add random numbers onto the end of this array when ever
I'm trying to add NSMutableArray to other NSMutableArray, a mutable array set as instance
Im trying to add a constraint to a reservation table, the reservation can either
I have been trying to add an object as an NSMutableDictionary to my array,
I'm trying to add two BitSet objects together (mutating one of them). This should
Thanks for you time and reading this. What I'm trying to do is figure
I am using JS to append array data to a table. I am trying
I'm trying to go through a mutable array searching for a given string. If
Ok, so I am trying to insert a dynamical data inside a row. This

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.