Subclassing a Foundation class cluster or a class Apple documents as final

ID

objectivec.correctness.forbidden_subclassing

Severity

low

Remediation Complexity

hard

Remediation Risk

medium

Remediation Effort

high

Resource

Api Misuse

Language

Objective-C

Description

This base class must not be subclassed. Foundation’s collection and value classes are class clusters: the public class is a facade and every instance you get back is really a private subclass, so a subclass of the facade inherits no storage, has to reimplement the full set of primitive methods by hand, and still loses whenever the framework hands back one of its own instances. UIImagePickerController is documented as not supporting subclassing at all. Compose instead - wrap an instance of the class in your own object - or use a category for added behaviour.

Rationale

This base class must not be subclassed. Foundation’s collection and value classes are class clusters: the public class is a facade and every instance you get back is really a private subclass, so a subclass of the facade inherits no storage, has to reimplement the full set of primitive methods by hand, and still loses whenever the framework hands back one of its own instances. UIImagePickerController is documented as not supporting subclassing at all. Compose instead - wrap an instance of the class in your own object - or use a category for added behaviour.

The following code illustrates the pattern detected by this rule:

// FLAGGED: Subclassing a Foundation class cluster or a class Apple documents as final
@interface TaggedString : NSString
@property (nonatomic, copy) NSString *tag;
@end

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved