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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:04:16+00:00 2026-05-27T07:04:16+00:00

The book I’m currently reading has me write the following code : -(IBAction)displaySomeText:(id)sender {

  • 0

The book I’m currently reading has me write the following code :

-(IBAction)displaySomeText:(id)sender {
    NSString *cow = @"Milk";
    NSString *chicken = @"Egg";
    NSString *goat = @"Butter";

    NSArray *food = [NSArray arrayWithObjects:cow, chicken, goat, nil];

    NSString *string = @"The shopping list is: ";
    string = [string stringByAppendingString:[food componentsJoinedByString:@", "]];

    [textView insertText:string];

}

I understand somewhat how arrays work but I need help understanding the following code

string = [string stringByAppendingString:[food componentsJoinedByString:@", "]];

I have never ever seen an instance where this is possible.

He has me create a ‘string’ object, from the NSString class, and then I’m doing this

string = [string stringByAppendingString:];

I’m confused. I have never seen an example where I create an object and then perform a method on the same object and store it in that exact same object.

For example, I know I can do this

NSSound *chirp;
chirp = [NSSound soundNamed:@"birdChirp.mp3"];

the above makes sense because I used the created object and performed a class method on it..

but I always assumed that the equivalent of the following code was NOT possible

chirp = [chirp methodNameEtc..];

I hope I explained my question well. If not I could always elaborate further.

  • 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-27T07:04:17+00:00Added an answer on May 27, 2026 at 7:04 am

    I think this is the heart of your question “I’m confused. I have never seen an example where I create an object and then perform a method on the same object and store it in that exact same object.”

    To answer that question, your not actually ‘storing it in the exact same object‘. What you are doing is confusing pointers and objects.

    Let’s just look at this line:

    string = [string stringByAppendingString:@"Hello"];

    In this line ‘string’ is a pointer, not the object it points to. What this line of code is saying is:
    “Object currently referenced by the pointer ‘string’, return to me a new NSString object whose text is your text with this text added. And when I get that new NSString object I ordered make the pointer ‘string’ point to that object instead.”

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

Sidebar

Related Questions

The book of IronPython In Action has the following code to read python script
The book I'm reading about Erlang has exercises in the back of it and
Book I’ learning from claims that intArray has two dimensions. But since calling intArray.GetLength(1)
My Book model has an author attribute which today is simply a CharField. The
The book of CLR via C# has this line at page 76. When you
The book Learning jQuery says IE has memory leak for the DOM object having
In book named Using C++ by Rob McGregor there is following example of using
The book I've been reading about Django mandates heavy usage of a command line
A book I was reading, on sql server 2008, mentions how you should not
While reading a book called Let us C I read that a function showbit()

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.