Oh gosh, you’re doing this from a category on NSData
!
So, in Objective-C [1] the methods on a class live in a single flat namespace. This causes all sorts of problems, but it’s especially bad for categories. If two subsystems within a process each use a category to add a method to a class and happen to choose the same method name, the results are undefined [2].
Given that, standard practice is to add prefixes to any method names that you add to common classes. In your case you could change your method name to -myFabulousApp_sha256
.
WebKit should be adding be using a prefix as well. I’d appreciate you filing a bug against it. Please post your bug number, just for the record.
Taking a step back, my general advice is that you avoid adding categories on classes you don’t ‘own’. I find that folks overuse categories for this sort of thing, and it’s just easier to using a standalone function:
extern NSString * sha256ForData(NSData * data);
Or, if you have an aversion to such functions, do something like this:
@interface MFAUtils: NSObject
+ (NSString *)sha256ForData:(NSData *)data;
@end
Note that you need a prefix on the class name (MFA
stands for My Fabulous App, obviously :-) because Objective-C classes also live in a single namespace.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] This isn’t true for Swift.
[2] Well, the process will eventually stabilise on using one or the other implementation, but a) that can change over time, and b) which one you eventually stabilise on is undefined.