Operators in Objective C and Swift

Common for Objective C and Swift
  • Assignment Operator ( = )
  • Arithmetic Operator
    • addition +,
    • Subtraction -, 
    • Multiplication *,  
    • Division /
  • Remainder (Modulo) Operator %
  • Unary plus operator (+), Unary minus operator (-), unary operator is prepended directly on the value it operates on.
  • compound assignment/short hand operators (x+=y, x-=y, x*=y, x/=y, x%=y, x&=y, x|=y, x^=y)
  • Increment (++) & decrement operator (—) {int x=9, int y: y= ++x , y = - - x } (Removed in Swift 3)
  • Relational/Comparison operators 
    • Equal to (a == b)
    • Not equal to (a != b)
    • Greater than (a > b)
    • Less than (a < b)
    • Greater than or equal to (a >= b)
    • Less than or equal to (a <=  b)
  • Logical Operator 
    • Logical Not (!a)
    • Logical AND (a && b)
    • Logical OR (a || b)
  • Ternary Conditional Operator ( if condition? expression 1 : expression 2 )
Swift Only
  • Range Operator 
    • Closed Range Operator '1…10', includes 1 and 10 in this range.
    • Half Open Range Operator '1..~10 , includes 1 but not 10
  • Nil-Coalescing Operator (x??y)
The nil-coalescing operator (x ?? y) unwraps an optional x if it contains a value, or returns a default value y if x is nil. The expression a is always of an optional type. The expression y must match the type that is stored inside x.

The nil Coalescing operator is shorthand for the below code:

x != nil ? x! : y

The code above uses the ternary conditional operator and forced unwrapping (x!) to access the value wrapped inside a when x is not nil, and to return x otherwise. The nil-coalescing operator provides a more elegant way to encapsulate this conditional checking and unwrapping in a concise and readable form.


  1. Right,Good to see these helpful information here iPhone Apps Development Company.Thanks lots for sharing them with us.

  2. Fabulous canvas..and thanks a lot for sharing these tips ,they are really helpful.keep it up I really enjoy the blog post.
    Technolgy, online reputation management,Business Information Blog

  3. Good work…unique site and interesting too… keep it up…looking forward for more updates.Good luck to all of you and thanks so much for your hard-work.
    subtitling company in bangalore,subtitling services india

  4. Everyone needs to advance their business. Today online presence for any business is a must. What's more, to get massive online presence, you need to enlist a web development company Bangalore and its enlisting is bit a tough task. It is not that you simply look through an internet searcher and pursuit out the correct web design organization.
    Website Design and Development Services in Bangalore | website design companies in bangalore

  5. Awesome article I really impress it’s very informative and useful.Thanks

    Custom Software Development Australia

  6. Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best. Hire iPhone Developers India