Last active
November 22, 2020 18:12
-
-
Save username0x0a/71d8677d14c9c2970fbc4033d1623ac1 to your computer and use it in GitHub Desktop.
Very useful macro to get around some mutable/immutable assignment issues for basic Foundation types.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface NSString (FoundationMutabilityType) | |
- (NSString *)copy; | |
- (NSMutableString *)mutableCopy; | |
@end | |
@interface NSDictionary<KeyType, ObjectType> (FoundationMutabilityType) | |
- (NSDictionary<KeyType, ObjectType> *)copy; | |
- (NSMutableDictionary<KeyType, ObjectType> *)mutableCopy; | |
@end | |
@interface NSArray<ObjectType> (FoundationMutabilityType) | |
- (NSArray<ObjectType> *)copy; | |
- (NSMutableArray<ObjectType> *)mutableCopy; | |
@end | |
@interface NSSet<ObjectType> (FoundationMutabilityType) | |
- (NSSet<ObjectType> *)copy; | |
- (NSMutableSet<ObjectType> *)mutableCopy; | |
@end | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Wincomplete-implementation" | |
@implementation NSString (FoundationMutabilityType) @end | |
@implementation NSArray (FoundationMutabilityType) @end | |
@implementation NSDictionary (FoundationMutabilityType) @end | |
@implementation NSSet (FoundationMutabilityType) @end | |
#pragma clang diagnostic pop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment