1>建议做缓存的时候采用 NSCache, 而不是 NSDictionary. 2>大多数情况下, NSCache 的用法与 NSDictionary 一样, 可以调用 objectForKey:, setObject:forKey:, removeObjectForKey: 3>开发者可以在任何线程上不加锁的修改NSCache
它可以很方便的把 URL 分成几个部分, 比如:
NSString *URLString = @"http://172.0.0.1:8888/api/ios?name=lcn" NSURLComponents *components = [NSURLComponents componentsWithString:URLString]; NSString *host = components.host; NSLog(@"%@", host);也可以用它创建或修改 URL
它可以处理非拉丁书写系统(例如:中文)和拉丁字母之间的转换:
NSMutableString *source = @"点通宝".mutableCopy; // 将中文转换成带声调的拼音 CFStringTransform((__bridge CFMutableStringRef)source, NULL, kCFStringTransformMandarinLatin, NO); NSLog(@"%@", source); // 将拼音的声调去掉 CFStringTransform((__bridge CFMutableStringRef)source, NULL, kCFStringTransformStripDiacritics, NO); NSLog(@"%@", source);另: 它不能处理日文(因为日文中可能出现汉字)