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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:09:50+00:00 2026-06-04T10:09:50+00:00

With objects, I can write an accessor to return nil if the object isn’t

  • 0

With objects, I can write an accessor to return nil if the object isn’t valid:

- (Weather *)howsTheWeather
{
    if (![WeatherNetwork isAvailable]) {
        return nil;
    }
    Weather *weatherNow = [WeatherNetwork getWeather];
    return weatherNow;
}

I’d like to do this with a CLLocationCoordinate2D, a struct for holding a latitude and longitude. I tried this:

- (CLLocationCoordinate2D)coordinate
{
    CLLocationCoordinate2D coord = CLLocationCoordinate2DMake(self.latitude, self.longitude);
    if (!CLLocationCoordinate2DIsValid(coord)) {
        return nil;
    }
    return coord;
}

But the compiler complains “Returning ‘void *’ from a function with incompatible result type ‘CLLocationCoordinate2D'”

What’s the best way to deal with this kind of situation? I was thinking of writing a separate method -(BOOL)isLocationValid:(CLLocationCoordinate2D)coordinate. Is there a better way to deal with this?

  • 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-04T10:09:52+00:00Added an answer on June 4, 2026 at 10:09 am

    A struct cannot be null. You will need to go with option 2 (checking the validity of the struct based on the data it contains). Alternatively you could wrap your struct in an pseudo-object that is capable of being nil’ed, but that seems alot of work for spurious benefit.

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

Sidebar

Related Questions

I can write an assertion message one of two ways. Stating success: assertEquals( objects
I have 3 objects. Object A has an event X that other objects can
Given any object in Ruby (on Rails), how can I write a method so
In Mongodb, you can write queries that include multiple attributes of objects and even
In Action Script 3, you can write a class that defines a dynamic object
In EJB 3.0 you can write your domain objecs, then convert them into entitities
Can i write oblects in java into file and retrieve the same?? In c++
I believe that UIView objects can delegate control to views in iOS programming. However,
I've often read that in the Sun JVM short-lived objects (relatively new objects) can
I have two objects that can be represented as an int, float, bool, or

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.