iOS 面试题目

2018-08-14  本文已影响0人  yuezishenyou

1.是否熟知CocoaPods?它是什么?如何运行的?

CocoaPods 是一个第三方管理工具。它能自动配置编译选项,,减少人为编译错误,拯救了开发者。

spec 文件描述

2.Apple Pay是什么?

苹果支付和微信支付宝支付的区别

3.iOS 后台多任务处理


    后台完成某些花费时间的特定任务
    后台播放音乐等
    位置服务
    IP电话(VoIP)
    Newsstand

详细讲解
https://www.jianshu.com/p/8a752f263e30


使用NSTimer的时候,发现每次APP进入后台,或者屏幕休眠后,NSTimer就会暂停。为了解决这个问题,翻阅了各种博客和网页。最终在伟大的stackoverflow上找到了一个简单并且真正可行的解决方案!代码如下:

[[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:nil];

    self.timer = [NSTimerscheduledTimerWithTimeInterval:1 target:selfselector:@selector(timeFireMethod)userInfo:nilrepeats:YES];

    [[NSRunLoop currentRunLoop] addTimer:self.timerforMode:NSRunLoopCommonModes];

4.iOS沙盒中Documents、Library和tmp的作用详解

Documents 
用户生成的文件,且应用程序不能重新创建的文件 应该保存在<Application_Home>/Documents 目录下面,且将通过iCloud自动备份。

Library
可以重新下载或者重新生成的数据,应该保存在<Application_Home>/Library/Caches 目录下面。

temp
只是临时使用的数据应该保存到<Application_Home>/tmp 文件夹

举例:
记事本应用。 用户生成的记事内容,保存在Documents 下面。用户看到的一些广告图,保存在library/cache。


//Home目录
 NSString *homeDirectory = NSHomeDirectory(); 
//Document目录 documents (Documents) 
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString *path = [paths objectAtIndex:0]; 

//Libaray目录 
various documentation, support, and configuration files, resources (Library) 
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES); NSString *path = [paths objectAtIndex:0]; 

//Cache目录 location of discardable cache files (Library/Caches) 
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES); NSString *path = [paths objectAtIndex:0];

上一篇下一篇

猜你喜欢

热点阅读