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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:41:54+00:00 2026-05-23T09:41:54+00:00

I come from an AS3 background. In AS3 when you assign an object to

  • 0

I come from an AS3 background. In AS3 when you assign an object to a var you do not copy the object to the var, the var becomes a reference to the object.

var myObject = new MyClass();
myObject.name = "Bananas";

var myRef = {};
myRef.ref = myObject;
trace(myRef.ref.name); // Bananas

myObject.name = "Mango";
trace(myRef.ref.name); // Mango

myObject = null;
trace(myRef.ref); // null

In Objective C, AFAIK, when you assign some object to some property of another object the “object is copied. My confusion comes from the fact that after using the temp object you can release it.

NSMutableString* myString = [[NSMutableString alloc] initWithString:@"Hello"];
[myLabel setText:myString]; 
[myString release];

… if you can release it means you do not need it anymore. So it is copied? or the “text” property in myLabel is a reference to myString?

As you can guess I’m just starting out in the world of Objective C.

TIA

  • 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-23T09:41:54+00:00Added an answer on May 23, 2026 at 9:41 am

    No. Objective-C also uses references (that’s why you see * after every class name, it’s actually a pointer). However, Obj-C also has a system of memory management. When you do myString = [[NSMutableString alloc] ...] you are creating a new string which you “own”. But when you call [myLabel setText:myString], the label will retain the string and effectively take ownership. Thus when you call [myString release], you are relinquishing ownership, but because the label still has ownership the string will not actually be deallocated from memory.

    I encourage you to read the Memory management programming guide for more information.

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

Sidebar

Related Questions

I come from a Java background, where packages are used, not namespaces. I'm used
First let me say I come from a background in Flash/AS3, which I realize
I come from a Java/AS3/Javascript background where all of my classes are organized into
I come from a .NET world and I'm new to writting C++. I'm just
I come from a mainly PHP background and make good use of the Apache
I come from a CVS background. I'm currently investigating using SVN for a project.
I come from a background of MoM. I think I understand ESB conceptually. However,
I come from classes object orientation languages and recently I have been learning those
I come from more of a Java background. In the last year or two,
I come from a Java background and with any servlets-based technology, it's trivial to

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.