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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T19:15:25+00:00 2026-05-14T19:15:25+00:00

Why should I declare local variables as ‘static’ inside a method? Like: static NSString

  • 0
  1. Why should I declare local variables as ‘static’ inside a method?
    Like: static NSString *cellIdentifier = @"Cell";
    Is it a performance advantage?
    (I know what ‘static’ does; in C context)

  2. What does this syntax mean?[someObj release], someObj = nil;
    Two statements?
    Why should I assign nil again?
    Is not ‘release’ enough?
    Should I do it for all objects I allocate/own? Or for just view objects?

  3. Why does everyone copy NSString, but retains other objects (in property declaration)?
    Yes, NSStrings can be changed, but other objects can be changed also, right?
    Then why ‘copy’ for just NSString, not for all?
    Is it just a defensive convention?

  4. Shouldn’t I release constant NSString? Like here:NSString *CellIdentifier = @"Cell";
    Why not? Does the compiler allocate/deallocate it for me?

  5. In some tutorial application I observed these (Built with IB):
    Properties(IBOutlet, with same ivar name): window, someLabel, someTextField, etc etc...
    In the dealloc method, although the window ivar was released, others were not.
    My question is: WHY? Shouldn’t I release other ivars(labels, textField) as well? Why not?

  6. Say, I have 3 cascaded drop-down lists.
    I mean, based on what is selected on the first list, 2nd list is populated
    and based on what is selected on the second list, 3rd list is populated.
    What UI components can reflect this best?
    How is drop-down list presented in iPhone UI?
    Tableview with UIPicker? When should I update the 2nd, 3rd list?
    Or just three labels which have touch events?

  7. Can you give me some good example tutorials about Core-Data?
    (Not just simple data fetching and storing on 2/3 tables with 1/2 relationship)

  8. How can I know whether my app is leaking memory? Any tools?

  • 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-14T19:15:26+00:00Added an answer on May 14, 2026 at 7:15 pm

    Why should I declare local variables as ‘static’ inside a method? Like: static NSString *cellIdentifier = @”Cell”; Is it a performance advantage? (I know what ‘static’ does; in C context)

    static is exaclt y the same in Objective-C as in normal C.

    What does this syntax mean?[someObj release], someObj = nil; Two statements? Why should I assign nil again? Is not ‘release’ enough? Should I do it for all objects I allocate/own? Or for just view objects?

    It depends on the context. It stops there being any chance of over-releasing the object because subsequent release messages will be sent to nil instead.

    Why does everyone copy NSString, but retains other objects (in property declaration)? Yes, NSStrings can be changed, but other objects can be changed also, right? Then why ‘copy’ for just NSString, not for all? Is it just a defensive convention?

    NSStrings can’t be changed, but NSMutableStrings (a subclass) can. Yes, it’s a defensive convention.

    Shouldn’t I release constant NSString? Like here:NSString *CellIdentifier = @”Cell”; Why not? Does the compiler allocate/deallocate it for me?

    Read the Cocoa Memory Management Rules. Did you obtain the constant string by alloc, copy or new? No you didn’t. Therefore, don’t release it unless you first retain it. Retaining constant strings does no harm.

    In some tutorial application I observed these (Built with IB): Properties(IBOutlet, with same ivar name): window, someLabel, someTextField, etc etc… In the dealloc method, although the window ivar was released, others were not. My question is: WHY? Shouldn’t I release other ivars(labels, textField) as well? Why not?

    Again, the memory management guidelines will help. If the object has retained the ivar (or created it with alloc, copy etc) it needs to be released.

    Say, I have 3 cascaded drop-down lists. I mean, based on what is selected on the first list, 2nd list is populated and based on what is selected on the second list, 3rd list is populated. What UI components can reflect this best? How is drop-down list presented in iPhone UI? Tableview with UIPicker? When should I update the 2nd, 3rd list? Or just three labels which have touch events?

    Pass. I don’t do UI programming on the iPhone.

    Can you give me some good example tutorials about Core-Data? (Not just simple data fetching and storing on 2/3 tables with 1/2 relationship)

    Apple’as Core Data Programming docs are a good place to start.

    How can I know whether my app is leaking memory? Any tools?

    Try http://developer.apple.com/iphone/library/documentation/Performance/Conceptual/ManagingMemory/Articles/FindingLeaks.html

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

Sidebar

Ask A Question

Stats

  • Questions 542k
  • Answers 542k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use: SELECT p.id as a, p.url as b, t.id as… May 17, 2026 at 3:22 am
  • Editorial Team
    Editorial Team added an answer There are two parts to the problem First Issue You… May 17, 2026 at 3:19 am
  • Editorial Team
    Editorial Team added an answer I thought I'd show the regex approach, too. It doesn't… May 17, 2026 at 3:18 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Should you declare the getters/setters of the class inside the .h file and then
How do you declare a method in C# that should be overridden (or overridable)
It's known that you should declare events that take as parameters (object sender, EventArgs
I have a function which contains a constructor: declare function local:Construct ($id) { <tag
Should methods in a Java interface be declared with or without the public access
Why main must be declared as if it has external linkage? Why it should
Should I start with Django or JavaScript?
Should the folders in a solution match the namespace? In one of my teams
Should you set all the objects to null ( Nothing in VB.NET) once you
Should I still be using tables anyway? The table code I'd be replacing is:

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.