代码杂记(功能方法 随时更新)

  1. NSString *strippedString=[searchTextstringByTrimmingCharactersInSet:[NSCharacterSetwhitespaceCharacterSet]];

   去掉前后空格


An object representing a URL (Universal Resource Locator). UIKit supports many schemes, includinghttp,https,tel,facetime, andmailto schemes.


- (BOOL)openURL:(NSURL *)url

func openURL(_url:NSURL) -> Bool

2.打开网址,跳转网页。

else if([@"url"isEqualToString:entityType])

        {

            NSMutableString* app_url = [NSMutableStringstringWithString:Onepromotion.entityId];

            

            if(!([app_url hasPrefix:@"http://"] || [app_url hasPrefix:@"https://"]))

            {

                [app_url insertString:@"http://"atIndex:0];

            }

            if ([[UIApplicationsharedApplication]canOpenURL:[NSURLURLWithString:app_url]]) {

                

                [[UIApplicationsharedApplication]openURL:[NSURLURLWithString:app_url]];

            }else{

                NSLog(@"app_url=%@",app_url);

            }

3.点击可以拨号

    [[UIApplicationsharedApplication]openURL:[NSURLURLWithString:[NSStringstringWithFormat:@"telprompt://%@",@"1008611"]]];//拨号 会出现提示框

[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",@"1008611"]]]; //直接拨号,不会出现提示

4.邮件

    [[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto://%@",@"tao.xu@wellav.com"]]];


5.利用FaceTime进行视频通话

    [[UIApplicationsharedApplication]openURL:[NSURLURLWithString:[NSStringstringWithFormat:@"facetime://%@",@"ytdxxt10@163.com"]]];


6.延迟加载(2s)

   dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

            [self loadTestData];


            [LDCollectView reloadData];

            [_headerView endRefreshing];

        });



7.获取当前终端的语言

    NSArray *array=[[NSUserDefaultsstandardUserDefaults]objectForKey:@"AppleLanguages"];

   NSLog(@"%@",array[0]);


8.数组的逆序


NSArray *tempArray = @[@1,@2,@3,@4];

    tempArray =   tempArray.reverseObjectEnumerator.allObjects;




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值