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

  • Home
  • SEARCH
  • 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 6649801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:49:02+00:00 2026-05-26T00:49:02+00:00

NSLog(@ — object id = %ld — , (long) [mp_list objectAtIndex : 0]); target_coordinate_2D

  • 0
    NSLog(@" --- object id = %ld --- ", 
          (long) [mp_list objectAtIndex : 0]);     

    target_coordinate_2D = [[mp_list objectAtIndex : 0] coordinate];

    // Some test code here which verifies that target_coordinate_2D   
    // gets assigned a valid "coordinate" value.

    [mapView addAnnotation : [mp_list objectAtIndex : 0]];

Consider the above 3 statements :

According to documentation, the NSArray’s method “objectAtIndex” should return an object. My understanding is the value returned is a numeric pointer to the object.

But what I got is :

--- object id = 0 ---
'NSInvalidArgumentException', reason: '-[... addObject:]: attempt to insert nil'

My questions are :

1

Why “object id” is nil ? Since target_coordinate_2D got assigned a valid value,
[mp_list objectAtIndex : 0] should indeed be a valid object with a valid “coordinate”
property.

2

On the last statement, I wish to add the object in mp_list to mapView. The NS Exception
thrown by the simulator is consistent of the fact that “[mp_list objectAtIndex : 0]” is
indeed nil. So there must be something I have missed about NSArray. What should be
done in order to assign an object to an array from another array ?

Hope that somebody knowledgable in this area can help …

http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html

  • 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-26T00:49:03+00:00Added an answer on May 26, 2026 at 12:49 am

    It sounds like mp_list itself is nil, which is why [mp_list objectAtIndex:0] is returning nil (because messaging nil returns nil).

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

Sidebar

Related Questions

NSLog give me this when i print some NSDictionary object. I see, that in
I have some NSLog calls that I do to keep myself from flying blind
My code is: NSLog(@saving jpeg); NSString *jpegFilePath = [NSString stringWithFormat:@%@/%@.jpeg,docDir, [self.Youtubearray objectAtIndex:0]]; NSData *data2
For an object it is NSLog(@some object %@, someObject); For decimal it is: NSLog(@some
The following code works as expected: NSLog(@%@, [NSString stringWithString:@test]; // Logs test But when
NSLog(@%@,variable); temp = @(null); if([variable isEqualToString:temp]) This is the code that I use and
I am currently using NSLog everywhere in my code just to test it, is
When I send an object to NSLog, I get a string with three attributes.
I am having trouble understanding why NSLog reports dog when the code is run.
I have the following code: NSLog(@items: %d, [items count]); NSLog(@allObjects: %d, [self.allObjects count]); [self.allObjects

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.