zoukankan      html  css  js  c++  java
  • iOS 开发中的一些注意点(安全、当前语言、时间格式化)

    1.重复运行项目,不重复构建项目(来自Heath Borders

    假如你一直在不停地调试同一个问题,你可以在不重复构建的情况下运行你的APP,这样:“Product>Perform Action>Run without Building” 

    2.禁用dylib钩子(来自Sam Marshall

    在你的“Other Linker Flags”里加上下面这行:

    -Wl,-sectcreate,__RESTRICT,__restrict,/dev/null
    

    3.NSBundle -preferredLocalizations

    某些时候,你需要知道APP当前使用的是什么语言。eg:优先语言列表中只有{英语,法语},但你的APP仅使用德语;调用[[NSLocal preferredLanguages] firstObject]返回给你的是英语,而不是德语。正确的方法是用[[NSBundle mainBundle] preferredLocalizations]方法。

    4.NSDateFormatter +dateFormatFromTemplate:options:locale:

    友情提示:假如你调用[NSDateFormatter setDateFormat],而没有调用[NSDateFormatter dateFormatFromTemplate:options:local:],n那么很可能出错。

    + (NSString *)dateFormatFromTemplate:(NSString *)template
                                 options:(NSUInteger)opts
                                  locale:(NSLocale *)locale
    

    不同地区有不同的日期格式。使用这个方法的目的:得到指定地区指定日期字段的一个合适的格式(通常你可以通过currentLocal查看当前所属地区)

    下面这个例子给我们表现了英式英语和美式英语不同的日期格式:

    NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
    NSLocale *gbLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_GB"];
     
    NSString *dateFormat;
    NSString *dateComponents = @"yMMMMd";
     
    dateFormat = [NSDateFormatter dateFormatFromTemplate:dateComponents options:0 locale:usLocale];
    NSLog(@"Date format for %@: %@",
        [usLocale displayNameForKey:NSLocaleIdentifier value:[usLocale localeIdentifier]], dateFormat);
     
    dateFormat = [NSDateFormatter dateFormatFromTemplate:dateComponents options:0 locale:gbLocale];
    NSLog(@"Date format for %@: %@",
        [gbLocale displayNameForKey:NSLocaleIdentifier value:[gbLocale localeIdentifier]], dateFormat);
     
    // Output:
    // Date format for English (United States): MMMM d, y
    // Date format for English (United Kingdom): d MMMM y
    
  • 相关阅读:
    jade反编译,把html编译成jade
    runtime环境下的jade
    jade过滤器
    jade-render-renderFile
    【[USACO17DEC]Standing Out from the Herd】
    bzoj 1396: 识别子串
    bzoj 4327:JSOI2012 玄武密码
    hihocoder 后缀自动机四·重复旋律6
    hihocoder 后缀自动机四·重复旋律7
    【[CTSC2012]熟悉的文章】
  • 原文地址:https://www.cnblogs.com/fuunnyy/p/5317797.html
Copyright © 2011-2022 走看看