Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. It was the main programming language supported by Apple for macOS, iOS, and their respective APIs (Cocoa and Cocoa Touch) before the introduction of Swift.
Objective-C Anti-Patterns Overview
Not Using ARC (Automatic Reference Counting)
Strong Reference Cycles
weak
or unsafe_unretained
properties for back-references to break these cycles. This is especially important in delegate patterns and parent-child relationships.Not Using Properties
Not Using Modern Objective-C Syntax
Massive View Controllers
Not Using Blocks for Asynchronous Operations
Not Using Designated Initializers
Not Using Class Extensions for Private Methods
Not Using Nullability Annotations
nullable
, nonnull
, null_unspecified
, null_resettable
) to clarify whether properties and method parameters/return values can be nil. This improves code clarity, enables better Swift interoperability, and helps catch nil-related bugs at compile time.Not Using Lightweight Generics
Not Using Categories and Extensions Appropriately
Not Using Enumerations for Constants
NS_ENUM
or NS_OPTIONS
for enumerated constants instead of #define or global constants. Enumerations provide type safety, better autocompletion, and make your code more readable and maintainable.Not Using instancetype for Initializers
instancetype
instead of id
as the return type for initializers and factory methods. This provides better type checking and enables the compiler to know the actual return type, improving autocompletion and catching errors at compile time.Not Using Appropriate Memory Management Semantics
copy
for immutable objects like NSString to prevent unexpected changes, weak
for delegates and other references that shouldn’t own the object, and expose mutable collections as readonly with private mutable versions.Not Using Appropriate Error Handling
Not Using Appropriate Concurrency Patterns
Not Using Proper Documentation
Not Using Appropriate Testing Patterns