Hurry! 20% Off Ends SoonRegister Now

iPhone – Defining Enum and Dot Syntax In Objective C

 

Defining Enum and Dot

An enumeration defines a common type for a group of related values and enables you to work with those values in a type-safe way within your code.

Inclined to build a profession as IOS Developer? Then here is the blog post on iPhone Development Certification Training.

An enumerator is a list of predefined variables. If you’re familiar with OBJECTIVE C data types like int and double, you know that you can define variables to hold or return an int and double values. Enumerators are also a data type – the only difference is that you create the data type. With enumerators, you can create variables that will hold only a value found only in the enumerator. Enumerators are declared with the help of the “enum” keyword

Enum is the user-defined data type, it improves the speed of execution of the keyword. Here, we use “enum” by default as it assigns values to range from 0,1,2,3…..

Note:-
We can manually assign values to enum values

Ex :- 1) ENUM                                 
            {                                                       
              ADMIN;                                            
              USER;                                             
             DEVELOPER,                                   
              TESTER,                                          
               };
EX:- 2)   ENUM  
              {
            ORANGE,
             PURPLE,
             CYAN,
            VIOLET,
             };

.h FILE:-

      @interface xyz
        {
       NSString * str;
    }
@ property (non atomic, retain) NS string x str;
@end

.m file:-

@ implementation
  @(void) view did load
   {
Ns string  * str; // str is local variable
Str = @ “hello ; is assigned to  the local variable
  Self. Str   =  @  “hello”; // hello is assigned to the instance variable.
// using of ‘dot’ syntax and messaging for the variables.
àSetting the value
       Self str = @ “hello:,
         (Or)
     [self. SetStr:,@ “Hello”];
àGetting the value
         Str2 = [self str];
        ( Or)
          Str2   = self. Str;
      [sup8 viewDidload];
 

 Note: – self is used to differentiate the coal variable and an instance method.

MindMajix Youtube Channel

Dot syntax:-

The dot syntax for getter and setter is new in objective C 2n which is a part of MAC OSX 10.5.  We can use either style (messaging or,) but choose only one for each project.

     The dot syntax should only be applied for setter and getter and not for the methods.

 

Frequently Asked iPhone Interview Questions & Answers

 

Job Support Program

Online Work Support for your on-job roles.

jobservice

Our work-support plans provide precise options as per your project tasks. Whether you are a newbie or an experienced professional seeking assistance in completing project tasks, we are here with the following plans to meet your custom needs:

  • Pay Per Hour
  • Pay Per Week
  • Monthly
Learn MoreGet Job Support
Course Schedule
NameDates
IOS Development TrainingDec 24 to Jan 08View Details
IOS Development TrainingDec 28 to Jan 12View Details
IOS Development TrainingDec 31 to Jan 15View Details
IOS Development TrainingJan 04 to Jan 19View Details
Last updated: 03 Apr 2023
About Author

I am Ruchitha, working as a content writer for MindMajix technologies. My writings focus on the latest technical software, tutorials, and innovations. I am also into research about AI and Neuromarketing. I am a media post-graduate from BCU – Birmingham, UK. Before, my writings focused on business articles on digital marketing and social media. You can connect with me on LinkedIn.

read less