Chapter 2:P rogramming in modern objective-c
by Matthijs Hollemans
Chapter II: The latest OC programming
Old habits die Hard, but if you ' re still writing objective-c in the style that is practiced when IPhone OS 2.0 first came Out (mid-2008) and then your ' re missing out in some really useful advancements that were made to the language recently.
Languages is living things, and computer Languages like Objective-c is no exception. As far as programming languages go, objective-c is already quite the Elder–about years old! For a while it is left-to-wither and die ... until the success of the IPhone breathed new life into it. Amazingly, Objective-c is now one of the most popular languages in the world.
Ever since Apple took charge of the compiler tools used to create IOS apps (GCC in the past, now LLVM and Clang), the comp Any have invested heavily in making the objective-c faster, simpler and better. With every recent new version of Xcode, the language have seen refinements that do it easier for us to write our apps.
Because you are missed some of these changes–a lot of books and code samples still cling to the old style of doing Things due to habit or lack of updates–this chapter would show you what to do the most of the these new techniques.
You'll review the improvements that were made to objective-c over the years–including the hot new stuff in Xcode 4.5– and learn to take advantage of these features to make your code shorter (less typing!), simpler, and easier to debug.
After reading this chapter, you'll have a elegant and modern objective-c coding style you can be proud of. Read Along–don ' t let your programming style get rusty!
Old habits are hard to change, and if you're still using the OC habit of iphone OS 2.0 (Mid-2008), you'll miss out on some useful improvements to the latest language.
Language is the activity of things, OC language is no exception. As for the programming language, OC is already the older language, it is already 30 years old! There was a time when it was rather depressed until the iphone's success injected new vitality into it, and now OC is one of the most popular programming languages in the world.
Since Apple is responsible for creating iOS apps (gcc in the past, now LLVM and Jingling), the company has invested heavily to make objective-c faster, simpler, and better.
With the latest version of each Xcode, the language has been refined to facilitate our writing applications.
A lot of books or code because of the habit or lack of new knowledge is still using the old code style, which may let you miss a change. This section will show you how to use these new technologies.
You'll review the changes that have taken place over the years-including the latest hottest Xcode4.5-and then use these new features to make your code shorter, simpler, and easier to debug!
After studying this section, you will have a good and up-to-date OC coding style that deserves your pride. Keep reading and don't let your coding style rust!
The Numberpedia app
In this chapter-going-take-a app that's written in old-fashioned objective-c style from the time of the IPhone OS 2.0 (also known as the "Stone age") and modernize it to take advantage of the exciting new features in Xcode 4.5 and the Clang 4.0 compiler.
The app itself is very simple. It ' s called "Numberpedia," and it consists of the screens. The first screen contains a table view this lists interesting numbers (that's, if you like numbers). Tap on a row and a "detail" screens opens that lets your edit the number, just in case you know better than.
In this chapter you will have an application written in the old OC language of the iphone OS2.0, which is improved by the new features of xcode4.5.
The application itself is very simple. The name is "Numberpedia", which consists of two pages. The first page is a tableview made up of interesting numbers (or, in other words, numbers you like). Clicking on a line jumps to a "details" page that lets you edit the number (only if your Pythagorean theorem is better).
You can find the source code for this app with this chapter ' s resources–open it up and take a quick look around before C Ontinuing.
You ' ll notice there is essentially the Classes:masterviewcontroller for the main list and Detailviewcontroller for the S Creen that lets you edit the numbers. The view controllers is designed in the Storyboard Editor and segue from one to the other.
The Masterviewcontroller contains a uitableview, and most of what it does happens in the table view data source methods. If you had ever worked with a table view before and then this code would look very familiar.
Find the code for this app in this resource-open the app and look at it between runs.
You will find that essentially there are two classes: the Masterviewcontroller class for the master list and the Detailviewcontroller class that lets you edit the numbers. These controllers are designed in storyboard and jump through the segue.
The Masterviewcontroller class includes a UITableView and implements his proxy method. If you have used table before, the code here is similar to the previous one.
-----, "", "" "" "", "" the Next Day "" "————
IOS 6 by Tutorials---chapter II-"First play"-"translation"