Objective-C Coding Practices
Application skill for Objective-C style learning (from the archived awesome-guidelines style capsules). Follow Apple Cocoa Coding Guidelines plus project clang-format; GitHub tab legacy trees normalize via formatter over time.
Core Principle
Objective-C quality is prefixed, documented headers with explicit ownership, copy immutables, designated inits, NSError for expected failures.
When to Use / NOT
- iOS/macOS ObjC and ObjC++ (
.m, .mm) libraries and app code.
- Setting up clang-format, clang-tidy, OCLint, Xcode analyze in CI.
NOT when:
- Swift-only modules, use Swift style foundations.
- Generated ObjC stubs, validate generators.
Workflow
- Layout, indent, braces, imports (
objc-style-formatting-layout.md).
- Naming, prefixes, categories (
objc-style-naming-prefixes.md).
- Memory, properties, init, copy (
objc-style-properties-memory.md).
- Docs/errors, Doxygen, NSError (
objc-style-docs-errors.md).
- Verify, clang-format, analyzer, header doc audit on exports.
Red Flags
- Two-letter class prefix
- Unprefixed category methods on shared types
getFoo accessor naming
- Dot syntax on non-property methods
- Missing memory semantics on properties
@synthesize without compiler requirement
- Iv ar access outside init/dealloc/custom accessor
- Messaging
self in -init/-dealloc for overridable selectors
+new usage
- Redundant ivar nil/zero initialization in init
- Individual Foundation subheaders instead of umbrella import
#include on ObjC headers
- Unsigned down-count loops
- Macro constants where
static const suffices
- Exceptions for normal control flow
- Undocumented public methods/properties
- Returning mutable where immutable contract promised
- No copy of mutable args in setters/async
- Weak long-lived references (refactor target)
- Mixed selector wrapping styles in one file
- Tomdoc/Doxygen missing nil documentation on object params
Verification
clang-format --dry-run / Xcode format on changed files
xcodebuild analyze or project static analyzer
- Public header Doxygen/nil-contract audit
- Capsule checklist on prefix + designated initializer chain
References
awesome-guidelines/references/objc-style-learning-note.md
awesome-guidelines/references/objc-style-formatting-layout.md
awesome-guidelines/references/objc-style-naming-prefixes.md
awesome-guidelines/references/objc-style-properties-memory.md
awesome-guidelines/references/objc-style-docs-errors.md
1---2name: objc-coding-practices3description: Use when authoring or reviewing Objective-C, Google/GitHub layout, 3+ char prefixes, property/copy semantics, designated initializers, Doxygen docs, NSError errors, literals, and clang-format/static analysis in CI.4---56# Objective-C Coding Practices78Application skill for Objective-C style learning (from the archived `awesome-guidelines` style capsules). Follow Apple Cocoa Coding Guidelines plus project `clang-format`; GitHub tab legacy trees normalize via formatter over time.910## Core Principle1112Objective-C quality is **prefixed, documented headers with explicit ownership**, copy immutables, designated inits, NSError for expected failures.1314## When to Use / NOT1516- iOS/macOS ObjC and ObjC++ (`.m`, `.mm`) libraries and app code.17- Setting up clang-format, clang-tidy, OCLint, Xcode analyze in CI.1819**NOT when:**2021- Swift-only modules, use Swift style foundations.22- Generated ObjC stubs, validate generators.2324## Workflow25261. **Layout**, indent, braces, imports (`objc-style-formatting-layout.md`).272. **Naming**, prefixes, categories (`objc-style-naming-prefixes.md`).283. **Memory**, properties, init, copy (`objc-style-properties-memory.md`).294. **Docs/errors**, Doxygen, NSError (`objc-style-docs-errors.md`).305. **Verify**, clang-format, analyzer, header doc audit on exports.3132## Red Flags3334- Two-letter class prefix35- Unprefixed category methods on shared types36- `getFoo` accessor naming37- Dot syntax on non-property methods38- Missing memory semantics on properties39- `@synthesize` without compiler requirement40- Iv ar access outside init/dealloc/custom accessor41- Messaging `self` in `-init`/`-dealloc` for overridable selectors42- `+new` usage43- Redundant ivar nil/zero initialization in init44- Individual Foundation subheaders instead of umbrella import45- `#include` on ObjC headers46- Unsigned down-count loops47- Macro constants where `static const` suffices48- Exceptions for normal control flow49- Undocumented public methods/properties50- Returning mutable where immutable contract promised51- No copy of mutable args in setters/async52- Weak long-lived references (refactor target)53- Mixed selector wrapping styles in one file54- Tomdoc/Doxygen missing nil documentation on object params5556## Verification5758- `clang-format --dry-run` / Xcode format on changed files59- `xcodebuild analyze` or project static analyzer60- Public header Doxygen/nil-contract audit61- Capsule checklist on prefix + designated initializer chain626364## References6566- `awesome-guidelines/references/objc-style-learning-note.md`67- `awesome-guidelines/references/objc-style-formatting-layout.md`68- `awesome-guidelines/references/objc-style-naming-prefixes.md`69- `awesome-guidelines/references/objc-style-properties-memory.md`70- `awesome-guidelines/references/objc-style-docs-errors.md`