Contents of NSString+sha1.h
:
#include <CommonCrypto/CommonDigest.h>
#include <Foundation/Foundation.h>
@interface NSString (sha1)
- (NSString *) sha1;
@end
Contents of NSString+sha1.m
:
#include "NSString+sha1.h"
@implementation NSString (sha1)
- (NSString *) sha1 {
const char *cstr = [self cStringUsingEncoding:NSUTF8StringEncoding];
NSData *data = [NSData dataWithBytes:cstr length:input.length];
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(data.bytes, data.length, digest);
NSMutableString *output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
for(int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
[output appendFormat:@"%02x", digest[i]];
return [NSString stringWithString:output];
}
@end
Contents of UIImage+RenderBatteryImage.m
:
#include "UIImage+RenderBatteryImage.h"
#include "NSString+sha1.h"
[...]
[@"A string (but not this one)" sha1]
When the code from the third file runs, I get this error:
-[__NSCFString sha1]: unrecognized selector sent to instance 0x12ee1caf0
What is causing this? I can confirm that I have no instances of uppercase SHA1 in any of my source files.