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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T18:00:24+00:00 2026-05-10T18:00:24+00:00

I know about the HIG (which is quite handy!), but what programming practices do

  • 0

I know about the HIG (which is quite handy!), but what programming practices do you use when writing Objective-C, and more specifically when using Cocoa (or CocoaTouch).

  • 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. 2026-05-10T18:00:25+00:00Added an answer on May 10, 2026 at 6:00 pm

    There are a few things I have started to do that I do not think are standard:

    1) With the advent of properties, I no longer use ‘_’ to prefix ‘private’ class variables. After all, if a variable can be accessed by other classes shouldn’t there be a property for it? I always disliked the ‘_’ prefix for making code uglier, and now I can leave it out.

    2) Speaking of private things, I prefer to place private method definitions within the .m file in a class extension like so:

    #import 'MyClass.h'  @interface MyClass () - (void) someMethod; - (void) someOtherMethod; @end  @implementation MyClass 

    Why clutter up the .h file with things outsiders should not care about? The empty () works for private categories in the .m file, and issues compile warnings if you do not implement the methods declared.

    3) I have taken to putting dealloc at the top of the .m file, just below the @synthesize directives. Shouldn’t what you dealloc be at the top of the list of things you want to think about in a class? That is especially true in an environment like the iPhone.

    3.5) In table cells, make every element (including the cell itself) opaque for performance. That means setting the appropriate background color in everything.

    3.6) When using an NSURLConnection, as a rule you may well want to implement the delegate method:

    - (NSCachedURLResponse *)connection:(NSURLConnection *)connection                   willCacheResponse:(NSCachedURLResponse *)cachedResponse {       return nil; } 

    I find most web calls are very singular and it’s more the exception than the rule you’ll be wanting responses cached, especially for web service calls. Implementing the method as shown disables caching of responses.

    Also of interest, are some good iPhone specific tips from Joseph Mattiello (received in an iPhone mailing list). There are more, but these were the most generally useful I thought (note that a few bits have now been slightly edited from the original to include details offered in responses):

    4) Only use double precision if you have to, such as when working with CoreLocation. Make sure you end your constants in ‘f’ to make gcc store them as floats.

    float val = someFloat * 2.2f; 

    This is mostly important when someFloat may actually be a double, you don’t need the mixed-mode math, since you’re losing precision in ‘val’ on storage. While floating-point numbers are supported in hardware on iPhones, it may still take more time to do double-precision arithmetic as opposed to single precision. References:

    • Double vs float on the iPhone
    • iPhone/iPad double precision math

    On the older phones supposedly calculations operate at the same speed but you can have more single precision components in registers than doubles, so for many calculations single precision will end up being faster.

    5) Set your properties as nonatomic. They’re atomic by default and upon synthesis, semaphore code will be created to prevent multi-threading problems. 99% of you probably don’t need to worry about this and the code is much less bloated and more memory-efficient when set to nonatomic.

    6) SQLite can be a very, very fast way to cache large data sets. A map application for instance can cache its tiles into SQLite files. The most expensive part is disk I/O. Avoid many small writes by sending BEGIN; and COMMIT; between large blocks. We use a 2 second timer for instance that resets on each new submit. When it expires, we send COMMIT; , which causes all your writes to go in one large chunk. SQLite stores transaction data to disk and doing this Begin/End wrapping avoids creation of many transaction files, grouping all of the transactions into one file.

    Also, SQL will block your GUI if it’s on your main thread. If you have a very long query, It’s a good idea to store your queries as static objects, and run your SQL on a separate thread. Make sure to wrap anything that modifies the database for query strings in @synchronize() {} blocks. For short queries just leave things on the main thread for easier convenience.

    More SQLite optimization tips are here, though the document appears out of date many of the points are probably still good;

    http://web.utk.edu/~jplyon/sqlite/SQLite_optimization_FAQ.html

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

Sidebar

Ask A Question

Stats

  • Questions 261k
  • Answers 261k
  • 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 The Oracle database installation includes scripts to install sample schemas.… May 13, 2026 at 11:40 am
  • Editorial Team
    Editorial Team added an answer If you're just looking for a better templating engine, why… May 13, 2026 at 11:40 am
  • Editorial Team
    Editorial Team added an answer It is not possible to use NHibernate from IronPython on… May 13, 2026 at 11:40 am

Related Questions

Would I violate the HIG by showing a tab bar on my first view
I know about the buttonMode property on a MovieClip (to get the hand cursor
I know about the __add__ method to override plus, but when I use that
I know about the bash history navigation with the Up and Down arrows. I

Trending Tags

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

Top Members

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.