Skip to content

Prefix category methods on core Objective C classes. #6

@tonyxiao

Description

@tonyxiao

Installed UI7Kit and thus FoundationExtension earlier but got a weird hard-to-debug crash. Took a while to figure out but finally tracked down the culprit to

@implementation NSMutableArray (Functional)

- (void)map:(NSAObjectUnaryOperator)mapper {
    NSUInteger count = self.count;
    for (NSUInteger i = 0; i < count; i++) {
        self[i] = mapper(self[i]);
    }
}

This category implementation overrode a previous category I have on NSMutableArray (though BlocksKit), which caused the crash at runtime. NSMutableArray is such a generic class and map: is such a generic method signature that it's almost guaranteed to run into method name clash problems for any projects of reasonable size and complexity, making FoundationExtension (and by extension UI7Kit) unusable :(. Could take an approach similar to MagicalRecord (https://github.com/magicalpanda/MagicalRecord/blob/develop/MagicalRecord/CoreData%2BMagicalRecord.h#L14), define a macro if you want the shorthand version offered by FoundationExtension, otherwise prefix all category methods on core Objective C classes with fe_ for Foundation Extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions