Coding Explorer Blog

Exploring how to code for iOS in Swift and Objective-C

  • Home
  • Apps
  • About
  • Contact

Archives for September 2013

Objective-C Classes and Usage of Variables

Last updated on June 25, 2014

So, for a little behind the scenes action.  The previous post about Header Files was originally going to be about classes.  But then after I started writing, I realized if I continued on to talking about classes, the post was going to be longer than I would want to read, so I decided to just split off the header file topic entirely, and save more discussion of classes for later.  That’s why I wrote about such an esoteric topic as “Header Files”.  I also like the word esoteric, so expect that to show up in this blog every so often.

Anyway, back to what I originally was going to write about, classes.  Classes are probably the most important thing in object oriented programming.  They are the very constructs that objects are created from.  For a physical analogy, lets say that we want to make a “landVehicle” class, by which I mean somethign that could discuss land vehicles like cars, trucks, tanks, whatever.

Aspects of Land Vehicles

  • They have variable speeds to drive at
  • They have an external color
  • They can drive different directions

So, if we had a game that needed land vehicles in it, we may want to write a class that describes them, so that the game can display them or use them somehow.  The first two describe an specific attribute of the land vehicle, while the third one refers to something it can do.  In a class, those first two could be stored as variables, and the third one could be used as a method, to cause the vehicle to drive a certain direction.  We’ve covered methods before, so I am going to discuss some of the details about variables below.

[Read more…]

Filed Under: General

Subscribe to the Coding Explorer Newsletter

* indicates required

Follow Us

Facebooktwitterrss

Recent Posts

  • Error Handling in Swift
  • Creating and Modifying a URL in your Swift App
  • Watch Connectivity in Swift — Application Context
  • watchOS Hello World App in Swift
  • API Availability Checking in Swift

Categories

  • Class Reference
  • General
  • Interface Builder
  • My Apps
  • Objective-C
  • Swift
  • Syntax
  • Tutorial
  • Uncategorized

Archives

  • May 2016
  • March 2016
  • February 2016
  • December 2015
  • July 2015
  • June 2015
  • April 2015
  • February 2015
  • January 2015
  • December 2014
  • November 2014
  • October 2014
  • September 2014
  • August 2014
  • July 2014
  • June 2014
  • May 2014
  • April 2014
  • March 2014
  • January 2014
  • November 2013
  • September 2013
  • August 2013
  • July 2013
  • Terms Of Use
  • Privacy Policy
  • Affiliate Disclaimer

Subscribe to the Coding Explorer Newsletter

* indicates required

Copyright © 2025 Wayne Media LLC · Powered by Genesis Framework · WordPress