background preloader

iOS

Facebook Twitter

9 Code Smells of Preprocessor Use - Quality Coding. Preprocessed food also smells [This post is part of the Code Smells in Objective-C series.] Every time you use the preprocessor, what you see isn’t what you compile. With few exceptions, using the C preprocessor is a code smell. C++ programmers have had this beat into them: “Don’t use the preprocessor to do something the language itself provides.” Unfortunately, more than a few Objective-C programmers have yet to get that message. Here’s a handy command to run from Terminal. It examines source files from the current directory down, showing preprocessor use that you should double-check. find . \( \( -name "*. This command builds in some exceptions. Here are some common preprocessor idioms, and how to replace them: 1. Let’s start with a simple one that comes from our C heritage: Smell Unless you’re delivering platform-agnostic C or C++ code, there’s no reason to use #include, along with the accompanying include guards. 2.

#define WIDTH(view) view.frame.size.width And this isn’t your dad’s C! 3. Create native mobile apps for multiple platforms │ HTML5/JavaScript and C++ developer tools. NME :: Create high-performance Windows, Mac, Linux, iOS, Android, BlackBerry, webOS, Flash and HTML5 applications, written with Haxe. Programming with Objective-C: About Objective-C. Objective-C is the primary programming language you use when writing software for OS X and iOS. It’s a superset of the C programming language and provides object-oriented capabilities and a dynamic runtime. Objective-C inherits the syntax, primitive types, and flow control statements of C and adds syntax for defining classes and methods. It also adds language-level support for object graph management and object literals while providing dynamic typing and binding, deferring many responsibilities until runtime. At a Glance This document introduces the Objective-C language and offers extensive examples of its use.

You’ll learn how to create your own classes describing custom objects and see how to work with some of the framework classes provided by Cocoa and Cocoa Touch. An App Is Built from a Network of Objects When building apps for OS X or iOS, you’ll spend most of your time working with objects. Categories Extend Existing Classes Protocols Define Messaging Contracts Prerequisites See Also.