一、AFNetworking POST字元串 修改位置AFURLRequestSerialization 修改前 修改後 二、查找一個字元串中的多個相同子字元串 ...
一、AFNetworking POST字元串
修改位置AFURLRequestSerialization
修改前
NSString * AFQueryStringFromParameters(NSDictionary *parameters) { NSMutableArray *mutablePairs = [NSMutableArray array]; for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { [mutablePairs addObject:[pair URLEncodedStringValue]]; } return [mutablePairs componentsJoinedByString:@"&"]; }
修改後
NSString * AFQueryStringFromParameters(NSDictionary *parameters) { if ([parameters isKindOfClass:[NSString class]]) return (NSString *)parameters; NSMutableArray *mutablePairs = [NSMutableArray array]; for (AFQueryStringPair *pair in AFQueryStringPairsFromDictionary(parameters)) { [mutablePairs addObject:[pair URLEncodedStringValue]]; } return [mutablePairs componentsJoinedByString:@"&"]; }
二、查找一個字元串中的多個相同子字元串
NSString *str = @"14 28 62 24 3 46 99 73 10 51 0 95 34 58 50 33 56 23 97 82 83 8 94 1 17 7 19 96 9 54"; NSString *searchString = @"1"; NSRange searchRange = NSMakeRange(0, [str length]); NSRange range; while ((range = [str rangeOfString:searchString options:0 range:searchRange]).location != NSNotFound) { NSLog(@"%@",NSStringFromRange(range)); searchRange = NSMakeRange(NSMaxRange(range), [str length] - NSMaxRange(range)); }