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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:44:33+00:00 2026-05-24T11:44:33+00:00

Say I have the following function that returns a CLLocationCoordinate2D , which is just

  • 0

Say I have the following function that returns a CLLocationCoordinate2D, which is just a struct that has two doubles (named longitude and latitude) in it:

- (CLLocationCoordinate2D)getCoordinateForHouse:(House *)house
{
    CLLocationCoordinate2D coordToReturn;
    coordToReturn.latitude = // get house's latitude somehow
    coordToReturn.longitude = // get house's longitude somehow

    return coordToReturn;
}

Can I basically treat this struct just like any other primitive type? For instance, if I call the function above in code somewhere else like this:

CLLocationCoordinate2D houseCoord = 
       [someClassThatTheAboveFunctionIsDefinedIn getCoordinatesForHouse:myHouse];

The value that was returned from the function is simply copied into houseCoord (just like any other primitive would act), right? I don’t have to worry about the CLLocationCoordinate2D ever being destroyed elsewhere?

Seems obvious to me now that this is probably the case, but I just need confirmation.

  • 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-24T11:44:33+00:00Added an answer on May 24, 2026 at 11:44 am

    This is an area where Objective-C inherits its behaviour directly from C — assigning structs causes a shallow copy. So if you have any pointers inside the structs then you’ll copy the pointer, not the thing pointed to. In C code you need to factor that in to your adhoc rules about ownership. In Objective-C the automatic reference counting compiler isn’t capable of dealing with references to objects within structs (or, I think, unions) so it’s smart not to become too attached to the idea in any event.

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

Sidebar

Related Questions

Say I have the following code: function One() {} One.prototype.x = undefined; function Two()
Say I have the following: std::vector<int> myints; and then I have a function that
Lets say I have the following code that returns number of anchor elements on
Say that have the following CTE that returns the level of some tree data
I have a function that has several outputs, all of which native, i.e. integers
Say somewhere in my Vim buffer that I have the following: function foo() {
Say I have the following function: foo <- function(x, y = min(m)) { m
Let's say I have the following function: sumAll :: [(Int,Int)] -> Int sumAll xs
Let's say we have the following function: foo <- function(x) { line1 <- x
Let's say we have the following method declaration: Public Function MyMethod(ByVal param1 As Integer,

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.