2016.1.8 个人总结

一.AFN 3.0使用

-(void)postNetUploadAndDownload:(NSString *)url str1:(NSString*)str1 key1:(NSString *)key1 str2:(NSString *)str2 key2:(NSString *)key2  mainkey:(NSString *)mainkey {

//    AFN3.0中 AFHTTPRequestOperationManager 被弃用
    AFHTTPSessionManager * manger = [AFHTTPSessionManager manager];
    manger.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"text/html", nil];
    manger.requestSerializer = [AFJSONRequestSerializer serializer];
    manger.responseSerializer = [AFJSONResponseSerializer serializer];

    NSMutableDictionary * strDic = [NSMutableDictionary dictionary];
    NSMutableDictionary * mainDic = [NSMutableDictionary dictionary];
    [strDic setValue:str1 forKey:key1];
    [strDic setValue:str2 forKey:key2];
    [mainDic setValue:strDic forKey:mainkey];


    [manger POST:url parameters:mainDic progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        NSLog(@"response==%@",responseObject);
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        NSLog(@"error==%@",error);
    }];
}

二. 网络解析碰到

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<__NSDictionary0 0x7fa982c007a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key loginname.'

原因,把NSMutableDictionary写成 NSDictionary

三.自定义Log显示打印行和所属的类
2016.1.8 个人总结_第1张图片

四.汉字转拼音

- (NSString * )transformToPinyin:(NSString *)str {
    NSMutableString *mutableString = [NSMutableString stringWithString:str];
    CFStringTransform((CFMutableStringRef)mutableString, NULL, kCFStringTransformToLatin, false);
    mutableString = (NSMutableString *)[mutableString stringByFoldingWithOptions:NSDiacriticInsensitiveSearch locale:[NSLocale currentLocale]];
return [mutableString stringByReplacingOccurrencesOfString:@"'" withString:@""];

}

NSString * str = [self transformToPinyin:@"月落乌啼霜满天"];
NSLog(@"%@",str);

五. 修改光标颜色

    _tf.tintColor = [UIColor blackColor];

你可能感兴趣的:(iOS学习总结)