Iphone NSString自定义md5类方法警告:

Iphone NSString自定义md5类方法警告:,iphone,xcode,nsstring,warnings,md5,Iphone,Xcode,Nsstring,Warnings,Md5,我已经将NSString的自定义类方法改为md5 NSString。 这是我的代码: NSString+CustomMethod.h #import <Foundation/Foundation.h> #import <CommonCrypto/CommonDigest.h> @interface NSString (CustomMethod) + (NSString*)MD5:(NSString *)string; @end #导入 #进口 @接口NSStrin

我已经将NSString的自定义类方法改为md5 NSString。 这是我的代码:

NSString+CustomMethod.h

#import <Foundation/Foundation.h>
#import <CommonCrypto/CommonDigest.h>


@interface NSString (CustomMethod)

+ (NSString*)MD5:(NSString *)string;
@end
#导入
#进口
@接口NSString(CustomMethod)
+(NSString*)MD5:(NSString*)字符串;
@结束
NSString+CustomMethod.m

#import "NSString+CustomMethod.h"

@implementation NSString (CustomMethod)

+ (NSString*)MD5:(NSString *)string
{
    // Create pointer to the string as UTF8
    const char *ptr = [string UTF8String];

    // Create byte array of unsigned chars
    unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];

    // Create 16 byte MD5 hash value, store in buffer
    CC_MD5(ptr, strlen(ptr), md5Buffer);

    // Convert MD5 value in the buffer to NSString of hex values
    NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
    for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) 
        [output appendFormat:@"%02x",md5Buffer[i]];

    return output;
}


@end
#导入“NSString+CustomMethod.h”
@实现NSString(CustomMethod)
+(NSString*)MD5:(NSString*)字符串
{
//将字符串的指针创建为UTF8
常量字符*ptr=[string UTF8String];
//创建无符号字符的字节数组
无符号字符md5Buffer[CC_MD5_DIGEST_LENGTH];
//创建16字节MD5哈希值,存储在缓冲区中
CC_MD5(ptr、strlen(ptr)、md5Buffer);
//将缓冲区中的MD5值转换为十六进制值的NSString
NSMutableString*输出=[NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH*2];
for(int i=0;i
这个Methodclass工作得很好,但编译器给了我一个提示:

警告:找不到类方法“+MD5:”(返回类型默认为“id”)[3]

如何删除此警告

PS:如果put#import“NSString+CustomMethod.h”没有显示警告,但这是一种解决方法,我创建了一个自定义方法类,在需要它的地方不包括我的自定义类

谢谢你的帮助

Put
#将“NSString+CustomMethod.h”导入
.pch
文件或您要使用它的文件中。

#导入
.pch
文件或您要使用它的文件中