• Skip to main content
  • Skip to primary sidebar

Ravi Shankar

Tweaking Apps

  • Swift
  • Tech Tips
You are here: Home / Apple / Variables in Objective-C

Variables in Objective-C

June 26, 2013 By Ravi Shankar Leave a Comment

Objective-C also uses variables for storing data in memory like other programming languages. The variables are defined based on the type data type that will be stored. The general rule followed for naming variable are

  1. Use the camel case convention for variable i.e the first word in lowercase and second word in uppercase. For example if you are planning to store name of station in a variable then you can name it as “stationName”.
  2. You can also find out datatype of variable and name accordingly. For example, “strName” can tell the variable is of string data type and holds a name.
  3. Variables must contain only letters and numbers also it is better to avoid using underscore character.
  4. Be descriptive and avoid single letter or confusing words.

The variables are declared by first defining the datatype, followed by description of variable.

Declaring primitive datatypes

Examples :-

int count = 1;

float width = 23.34;

Declaring Objects

NSString *description;

NSArray *months;

The object variables are preceded with * before the description of variable.

Filed Under: Apple, Develop Tagged With: Apple, Objective C, Variables

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

TwitterLinkedin

Recent Posts

  • How to block keywords in Jio broadband
  • How to disable opening an app automatically at login in Mac
  • How to set preferred Wifi network on Mac
  • Attribute Unavailable: Estimated section warning before iOS 11.0
  • How to recover Firefox password from Time Machine backup

Pages

  • About
  • Privacy Policy
  • Terms and Conditions

Copyright 2022 © rshankar.com

Terms and Conditions - Privacy Policy