Property of a class with a mutable subclass is not declared copy

ID

objectivec.correctness.mutable_property_copy

Severity

low

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Api Misuse

Language

Objective-C

Description

This property’s type has a mutable subclass, so a caller can assign an NSMutable…​ instance and keep mutating it afterwards: the object’s state then changes underneath it, with no setter call and no KVO notification. Declare the property copy so the setter takes an immutable snapshot. A property that is meant to hold a mutable collection should be typed as the mutable class and stay strong.

Rationale

This property’s type has a mutable subclass, so a caller can assign an NSMutable…​ instance and keep mutating it afterwards: the object’s state then changes underneath it, with no setter call and no KVO notification. Declare the property copy so the setter takes an immutable snapshot. A property that is meant to hold a mutable collection should be typed as the mutable class and stay strong.

The following code illustrates the pattern detected by this rule:

@interface Article ()
// FLAGGED: Property of a class with a mutable subclass is not declared copy
@property (nonatomic, strong) NSString *title;
@end

@implementation Article
@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