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 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 529k
  • Answers 529k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I can’t use the NSDateFormatter because I need an NSDate… May 16, 2026 at 11:11 pm
  • Editorial Team
    Editorial Team added an answer You can use SVG images for CSS sprites just as… May 16, 2026 at 11:11 pm
  • Editorial Team
    Editorial Team added an answer Erm... no. You don't have to put a div around… May 16, 2026 at 11:11 pm

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

I am having a static method .In the method when I decalare a variable
Is there any reason why I could (or should) not declare dependency properties as
I'm going to save tutorials and snippets. How big should I declare the column?
I have a web task for counting some data inside DB. I must count
These are the ones I've come across: Inability to change the body of a
I'm writing some optimized C code that basically runs through an array and does
To tailor your scripts toward mp2, avoiding the need for any compatibility wrappers and
Why is it that in a C# switch statement, for a variable used in
I found the following rather strange. Then again, I have mostly used closures in
DataflowAnomalyAnalysis: Found 'DD'-anomaly for variable 'variable' (lines 'n1'-'n2'). DataflowAnomalyAnalysis: Found 'DU'-anomaly for variable 'variable'

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.