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. 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. If you’re writing your own class, start by providing a description of the class that details the intended public interface to instances of the class. Categories Extend Existing Classes Protocols Define Messaging Contracts Blocks Simplify Common Tasks
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. Here’s a handy command to run from Terminal. 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 Just because you’re in Objective-C doesn’t mean you can’t use plain C functions! And this isn’t your dad’s C! static inline CGFloat width(UIView *view) { return view.frame.size.width; } 3. Now we begin a set of preprocessor smells around constants. #define kTimeoutInterval 90.0 If a constant is used only within a single file, make it a static const.
Related:
Related: