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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:58:14+00:00 2026-05-29T18:58:14+00:00

I tried looking but couldn’t find any help. – (NSArray *)sushiTypes { return _sushiTypes;

  • 0

I tried looking but couldn’t find any help.

- (NSArray *)sushiTypes {
    return _sushiTypes;
}

- (void)setSushiTypes:(NSArray *)sushiTypes {
    [sushiTypes retain];
    [_sushiTypes release];
    _sushiTypes = sushiTypes;
}

What I would like to know is, while I was working this tutorial, I can’t figure out why he is retaining the argument. I tried commenting out that retain statement, and the program works the same, no leaks. So is that just unnecessary?

I’d also like to add the fact that, I called a method like this

self.sushiTypes = [[NSArray alloc]initWithObjects:"objects...];

But when I debug it, instead of going to the -(NSArray *)sushiTypes method, it goes to the setSushiTypes method. Why is 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-05-29T18:58:18+00:00Added an answer on May 29, 2026 at 6:58 pm

    You will be pointing _sushiTypes to the value of sushiTypes. Since _sushiTypes is an instance variable, you need to take ownership of this object by retaining it. If you fail to do so and all other owners of this object releases it, this memory will be freed, leaving your instance variable to point to garbage and your app will crash.

    It is important to note the order of messages in the setter as well. You need to call

    [sushiTypes retain];
    

    first, since _sushiTypes and sushiTypes might be pointing to the same object. If you swop them around and call release first, the memory might be freed before you get a chance to claim ownership.

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

Sidebar

Related Questions

I tried looking up other issues but couldn't find anything to match so here
First post here, I have tried searching but couldn't find what I'm looking for
I have tried looking all over the net for some help, and couldn't find
I've tried looking in Java->Editor, General->Appearance->Colors And Fonts, General->Editors->Text Editors->Annotations, but couldn't find it
OK I tried looking through the mySQL threads but I couldn't find what I
I've tried looking at similar problems, but could not easily find one that helped
I've tried to find a way to do this, but without success. I'm looking
I have tried looking all over the place and couldn't find a good solution
I know silly question but i tried looking it up on Google with no
I've tried looking around and there are similar problems, but mine is way more

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.