[Objective-C] NSURL, NSMutableArray, and NSMutableDictionary

Objective-C is such a versatile language. One of the main hardships when coding with Objective-C is that the language provides many different methods for solving the same problems. This is due to its robust API, with a plethora of library methods that can be utilized.

NSMutableArray gives you the ability to add or remove items from locations within a collection. There are many built-in methods that can be used to change and arrange items within the mutable array. Arrays are a great way to reliably record the order of their elements, and as such, make a great tool for sorting and manipulating lists of data.

NSURL is very useful in creating objects that contain the location of a particular resource on a remote server. I will explain its use in the coding challenge below. For now, one of the benefits of NSURL is the ability manipulate the contents of a particular file on a remote server.

NSMutableDictionary gives the dictionary interface to a particular object, allowing that object to hold mutable keys and values. Keys and values are paired within a dictionary, and each Key must be unique within a particular dictionary.

One of the more difficult beginner tasks I encountered in Objective-C was to build a program that could read a text file from a remote location on the computer, and store the contents of the text file within a mutable dictionary.

Before we begin to type code, we must approach this task by asking the right questions: What do I actually need to do? If I am not sure, how should I break it down in to smaller pieces? What should be displayed at the end? What objects are required in order for this program to work? I found that the task at hand had these requirements:

  1. An NSURL object to read and pull the contents of the text file.
  2. An NSArray componentsSeparatedByString method to copy the contents of the text file to an NSArray object.
  3. A Class that will initialize an object for storing the contents of the NSArray object.
  4. An NSMutableArray for storing the initialized object.

After we’ve asked the questions, then we can begin to attempt the coding process.

Advertisements

Programming Dreams

There’s something so fulfilling about churning out code, even in its most simplest structures. I believe that this is the joy of creation. It takes an enormous amount of logic, problem solving, and creativity.

To be quite honest, this is similar to dancing in the mind. I was a professional dancer and took it seriously throughout high school, college, and the first couple years after that. I have, and still am affected by choreographic thinking. It actually compliments the development process of code quite well. I find myself conscious about UI/UX before writing the code. I am also more aware of the structure and modulability of my code. It’s a very nice perspective to have, and I hope to continually improve upon it.

Another week, another rollercoaster of emotional lows and highs as I continue to navigate the landscape of coding concepts. It has been challenging, but extremely rewarding. I decided to begin with the C programming language. Some individuals may wonder why C is so important if iOS Apps are programmed mostly in Objective-C (and Swift ), and there is a very good reason for this:

Objective-C is a superset of C. This means that all the features of the C language are available within Objective-C. Therefore, it only makes sense to have a general understanding of C, as this will provide greater understanding of the features in Objective-C.

 

Over and out!