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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:01:56+00:00 2026-06-15T21:01:56+00:00

Say I have a method that takes a CLLocationCoordinate2D. I can’t pass nil directly

  • 0

Say I have a method that takes a CLLocationCoordinate2D. I can’t pass nil directly to that in code; the compiler complains. However, the following compiles. So what happens at runtime?

CLLocation* loc = nil;
[self passMeCoordinates:loc.coordinate];
  • 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-15T21:01:58+00:00Added an answer on June 15, 2026 at 9:01 pm

    This is an interesting question. I assume your earlier code was:

    [self passMeCoordinates:nil];
    

    The compiler complains about this because CLLocationCoordinate2D is not an object. It’s a C-style struct. So, you can’t pass an object/pointer (nil) where a struct is expected. (They’re not the same size, etc.)

    If I slightly paraphrase your code to:

    CLLocation* loc = nil;
    CLLocationCoordinate2D coord = loc.coordinate;
    [self passMeCoordinates:coord];
    

    The question comes down to “what value does coord have”. As you may know, the rule in Objective-C is that if you send a message to nil (as we do here — loc.coordinate is equivalent to [loc coordinate]), then you get back 0. But what if we’re expecting a struct? As I just mentioned, it’s not the same size as an integer. Well, it turns out that the result depends on what compiler you’re using:

    LLVM 3.0+ (Xcode 4.2+): returns all zeros, so it’s equivalent to a coordinate of (0,0): Can I rely on nil UIView returning CGRectZero for its frame?

    LLVM Earlier/GCC: a struct can be filled with garbage/undefined contents, so it could be anything.

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

Sidebar

Related Questions

Say I want to have a method that takes any kind of number, is
Let's say I have a subroutine/method that a user can call to test some
Let's say you have a business logic method that can perform some operation across
Let's say I have a method that takes a class, which is called like
Let's say I have a Player class. It has a Move method that takes
Say you have a method that takes a threshold and an input raises an
Say I have a method that takes an int as a string and returns
Let's say I have a method m() that takes an array of Strings as
say, I have a generic command trait with an execute method that takes an
I have a method, say method1(), that takes a while to run. During it's

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.