I have the following problem that I do not succeed to solve. Your help will be appreciated.
To calculate a md5 from a NSS tring, a category has been defined by :
NSString-md5.h
@interface NSString (MD5)
- (NSString *)MD5String;
@end
NSString-md5.m
#import <CommonCrypto/CommonDigest.h>
#import "NSString-md5.h"
@implementation NSString(MD5)
- (NSString *)MD5String
{is
const char *cstr = [self UTF8String];
unsigned char result[16];
CC_MD5( cstr, strlen(cstr), result );
return [NSString stringWithFormat:
@"%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
result[0], result[1], result[2], result[3],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
result[12], result[13], result[14], result[15]
];
}
@end
calling code (extract)
#import "NSString-md5.h"
...
NSLog(@"1 %@ ",message.text);
[message.text MD5String];
aborts with error message :
2013-03-03 19:06:14.104 coffreFort[1230:11303] 1 aze
2013-03-03 19:06:22.777 coffreFort[1230:11303] -[__NSCFString MD5String]: unrecognized selector sent to instance 0x71e62b0
2013-03-03 19:06:22.777 coffreFort[1230:11303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString MD5String]: unrecognized selector sent to instance 0x71e62b0'
message.text is an IBOutlet defined by
@property (weak, nonatomic) IBOutlet UITextField *message;