small skill~

一、判斷真機和模擬器
#if
TARGET_IPHONE_SIMULATOR #define SIMULATOR 1 #elif TARGET_OS_IPHONE #define SIMULATOR 0 #endif

史上最全第三方庫收集https://github.com/liuyuanming/iOSLibraryCollections

二、iOS9 漢字轉編碼html

 
 

    NSString *uu = [cityName stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];git

三、去掉navigationcontroller push返回時的標題(木有反作用)github

  [[UIBarButtonItem appearance]  setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60forBarMetrics:UIBarMetricsDefault]  數組

四、調節屏幕亮度app

 

    [[UIScreen mainScreen] setBrightness:value];編碼

五、對數組裏面的字典進行排序spa

    NSDictionary *dic1 = @{@"name":@"1"};指針

    NSDictionary *dic2 = @{@"name":@"4"};code

    NSDictionary *dic3 = @{@"name":@"2"};htm

    NSDictionary *dic4 = @{@"name":@"7"};

    NSDictionary *dic5 = @{@"name":@"3"};

    NSDictionary *dic6 = @{@"name":@"5"};

    NSMutableArray *arr = [NSMutableArray arrayWithObjects:dic1,dic2,dic3,dic4,dic5,dic6, nil];

     //

    NSSortDescriptor *sortByName = [NSSortDescriptor sortDescriptorWithKey:@"name"

                                                            ascending:YES];

    NSArray *sortDescriptors = [NSArray arrayWithObject:sortByName];

    NSArray *sortedArray = [arr sortedArrayUsingDescriptors:sortDescriptors];

    NSLog(@"%@",sortedArray);

 

六、Nonnull區域設置(Audited Regions)

若是須要每一個屬性或每一個方法都去指定nonnull和nullable,是一件很是繁瑣的事。蘋果爲了減輕咱們的工做量,專門提供了兩個宏:NS_ASSUME_NONNULL_BEGIN和NS_ASSUME_NONNULL_END。在這兩個宏之間的代碼,全部簡單指針對象都被假定爲nonnull,所以咱們只須要去指定那些nullable的指針。

七、快速找出數組中的最大值

NSComparator YYcmptr = ^(id obj1, id obj2){

    if ([obj1 integerValue] > [obj2 integerValue]) {

        return (NSComparisonResult)NSOrderedDescending;

    }    

    if ([obj1 integerValue] < [obj2 integerValue]) {

        return (NSComparisonResult)NSOrderedAscending;

    }

    return (NSComparisonResult)NSOrderedSame;

};

用法:

    NSArray *dataArray = @[@"22",@"321",@"11",@"222",@"33"];

    NSArray *arr = [dataArray sortedArrayUsingComparator:YYcmptr];

    NSLog(@"%@",[arr lastObject]);

八、iOS 8.0 設置啓動圖

http://www.360doc.com/content/16/0320/20/10408243_543891288.shtml

相關文章
相關標籤/搜索