iOS8 新特性

1. NSProcessInfo -isOperatingSystemAtLeastVersion####

// 拿当前操作系统的信息
NSProcessInfo * info = [NSProcessInfo processInfo];
    NSOperatingSystemVersion version = {8,0,0};
    [info isOperatingSystemAtLeastVersion:version];
    NSLog(@"%@",[info operatingSystemVersionString]);

2. 新的NSFormatter子类####

  • Foundation中严重缺失的一项功能就是不能处理重量和长度单位转换。在iOS 8和OS X Yosemite中,引进了三个新类NSEnergyFormatter,NSMassFormatter和NSLengthFormatter来弥补这一缺失。

  • 这使得NSFormatter子类的数量翻了一倍, 之前只有NSNumberFormatter,NSDateFormatter和NSByteCountFormatter。
    虽然这些都是Foundation的子类,但是它们主要都是在HealthKit当中使用。

// 新类 主要都是在HealthKit当中使用
//NSEnergyFormatter使用焦作为能量的原始单位,当处理健康信息时,则使用卡.
[NSEnergyFormatter class];
//虽然质量是物质存在的基本单位, 在HealthKit中,它主要指的是身体重量.
[NSMassFormatter class];
//NSFormatter的最后一个新子类是NSLengthFormatter. 我们可以把它想象为MKDistanceFormatter的加强版。
[NSLengthFormatter class];

3. 查找字符串方法####

    NSString *ss = @"abc";
    BOOL res1 = [ss containsString:@"a"];
    // 忽略大小写
    BOOL res2 = [ss localizedCaseInsensitiveContainsString:@"Ab"];

4. WKWebKit####

  • UIWebView已死. WKWebView万岁.
  • WKWebView提供了Safari级别的性能,并且在UIWebView的基础上提供了更多的配置选项

5. NSQualityOfService####

  • NSOperation中的优先级配置
operation.queuePriority = NSOperationQueuePriorityVeryHigh;

6. 指纹识别####

// 先验证能不能用指纹
LAContext *context = [[LAContext alloc] init];
    __block  NSString *msg;
    
    NSError *error;
    BOOL success;
    success = [context canEvaluatePolicy: LAPolicyDeviceOwnerAuthenticationWithBiometrics error:&error];
    if (success) {
        NSLog(@"指纹识别 可用");
    } else {
        NSLog(@"指纹识别 不可用");
    }
    // 弹出试指纹识别器
    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"验证理由" reply:
     ^(BOOL success, NSError *authenticationError) {
         if (success) {
             msg = @"验证成功";
             
         } else {
             msg = @"验证失败";
         }
         NSLog(@"%@",msg);
     }];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容