iphone-common-codes-ccteam源代码 CCNSPredicate.m

//
// CCNSPredicate.m
// CCFC
//
// Created by xichen on 11-12-27.
// Copyright 2011 ccteam. All rights reserved.
//


#import "CCNSPredicate.h"




@implementation NSPredicate(cc)


// returns whether the str is in accordance with the format
+ (BOOL)isValidFormat:(NSString *)str withFormat:(NSString *)format
{
NSPredicate *predicate = [NSPredicate predicateWithFormat:
@"SELF MATCHES %@", format];

return [predicate evaluateWithObject:str];
}


// not ok
+ (BOOL)isChineseChar:(NSString *)str
{
return [self isValidFormat:str withFormat:@"[\u4e00-\u9fa5]"];
}


@end

 

可能有更新:

googlecode链接地址:http://code.google.com/p/iphone-common-codes-ccteam/source/browse/trunk/CCFC/files/CCNSPredicate.m

github地址: https://github.com/cxsjabc/iphone-common-codes-ccteam/tree/master/CCFC/files/CCNSPredicate.m

 

你可能感兴趣的:(iPhone)