- (NSString *)randomStr:(NSString *)methodName
{
NSString *string = @"";
NSString * newMethod = @"";
if ([methodName rangeOfString:@":"].location != NSNotFound) {
if ([methodName componentsSeparatedByString:@":"].count >= 2) {
NSArray * array = [methodName componentsSeparatedByString:@":"];
for (int i = 0; i < array.count; i++) {
NSString * newStr = [self randomStr:array[i]];
if (![newStr isEqualToString:@""] && newStr != nil) {
newMethod = [newMethod stringByAppendingFormat:@"%@:",newStr];
}
}
return newMethod;
}
}
else
{
for (int i = 0; i < methodName.length; i++) {
int number = arc4random() % 36;
if (number < 10) {
int figure = arc4random() % 10;
NSString *tempString = [NSString stringWithFormat:@"%d", figure];
string = [string stringByAppendingString:tempString];
}else {
int figure = (arc4random() % 26) + 97;
char character = figure;
NSString *tempString = [NSString stringWithFormat:@"%c", character];
string = [string stringByAppendingString:tempString];
}
}
}
return string;
}
网友评论