Showing posts with label objective-c. Show all posts
Showing posts with label objective-c. Show all posts

Sunday, January 11, 2015

Resources for Beginning iOS Development

Recently, a coworker was interested in learning iOS development and asked me to recommend to him a few resources for learning and I thought that I would also share this here.

Here are a couple resources for learning iOS:

Intro Books
1. iOS Programming: The Big Nerd Ranch Guide (4th Edition) - This book only covers iOS 7 and Objective-C, but a lot of the same concepts will apply in iOS 8. This would be good intro to iOS and also learning Objective-C. Some of the text might be out of date since the Xcode UI has changed a little bit. I originally started learning with the Beginning iPhone Development book (below), and I read this one after; I thought that the Big Nerd Ranch book went in to more in depth on almost all the topics and I was able to pick a few tips on how to better structure my code.

2. Beginning iPhone Development with Swift: Exploring the iOS SDK - This book is also gives a good intro to iPhone development, but this one is written for iOS 8 and is in Swift if you want to skip the Objective-C part.

Learning Swift
1. I recommend just reading Apple's book on Swift to learn the language. It's available in iBooks here and on the web here. 
2. There is also a second part of the book above that covers using Swift with Cocoa and Objective-C, which goes into more advanced topics but is a good follow up read after reading the first part. The iBooks link is here.

A common question I see is should I learn Swift or Objective-C? I think that if you are looking for a job as a iOS developer, you will need to learn both because most likely the company/client already has existing code that is in Objective-C. You can mix and match Swift and Objective-C code, but you need an understanding of both to do so. If you are able to develop an app from scratch, you can probably get away with only learning Swift. It is also good to point out that the 3rd party library support for Swift is very weak right now, so if you don't mind reinventing the wheel (a good way to learn) then this is the way to go. You can also always refer to open source libraries written in Objective-C and convert them to Swift yourself (another benefit for learning both languages).

Other resources (tutorial sites and blogs)
1. http://www.raywenderlich.com/ - This site has a lot of useful tutorials for not only beginners but also intermediate and advanced iOS developers. When I was first starting out, I frequented this site and tried to do as many tutorials as I could. Even still today, I find myself visiting this site to continue learning.
2. http://nshipster.com/ - This iOS blog is written by the creator of AFNetworking and has a lot of in depth articles on Cocoa, Objective-C and Swift topics that are commonly overlooked.
3. https://iosdevweekly.com/ - This newsletter is a great way to get a pulse on the iOS community. I've been able to learn about a lot of useful tools and libraries from this weekly email.
4. WWDC videos (all years) - The videos from the WWDC presentations are extremely useful, but can be quite advanced and dry sometimes. If you are unsure of what the best practice of doing something is, I would recommended these videos; It's also a great way to learn about the new things that were introduced in every new version of iOS. Also see ASCIIwwdc.

Hopefully this is a good enough start. There is also always the Apple docs (sometimes confusing and hard to find), Google and Stack Overflow. Good luck!

Tuesday, August 19, 2014

Coding Styles and Standards

One of the main reasons for having coding standards is to keep your code readable by everyone. By enforcing standards and formatting, the code base becomes consistent, and anyone can easily understand the structure of the code because he will be more familiar with what to expect. It is also very useful when a new developer joins the team because once he is familiar with the patterns, he will be able to easily read the existing code, which results in a more pleasant experience.
In this example, I will define coding standards for an iOS project (which uses Objective-C). We will take advantage of the fact that code formatting can be automated in XCode by using a plugin. The coding style that I chose is based on the Chromium style guide, but I made a few modifications, which can be found in the `.clang-format` file. Feel free to make changes as you see fit; All of the options are defined here LLVM Coding Standards.
Installation
1. Install Alcatraz, the package manager for XCode.
`curl -fsSL https://raw.github.com/supermarin/Alcatraz/master/Scripts/install.sh | sh`
2. Select `Package Manager` from the `Window` menu and search for `ClangFormat` and install that plugin.
3. Select `Clang Format` from the `Edit` menu, and click on `File`. This will load formatting settings from the `.clang-format` file that is located in the repository.
4. When you want to format a file, go to the `Clang Format` menu and select `Format File in Focus`. You can also enable `Enable Format on Save` to have the plugin automatically format the file when you save it. You can also bind formatting to a keyboard shortcut, refer to the ClangFormat homepage for more options.

Additional Standards

The automatic code formatter does not implement all the standards we would like to follow. There are some standards that need to be enforced by the developer himself because they can't be automated. Please refer to https://github.com/paulsfds/objective-c-style-guide to see some examples.

Other Languages

Coding standards are universal and there exists some popular ones for other languages. I would also suggest searching on Google for popular standards for your favorite language. Also, many well established companies such as Google have their own coding standards that are available to the public. Here are a few popular ones to take a look at:
JavaScript
Ruby
Objective-C
C++
What are your favorite coding styles and standards?