5.线程
5.1 GCD
- GCD是一套多线程库,可以有效的替换NSThread或者NSOperation。它的基本结构是
dispatch_async(queue, block);
参数中的queue可以通过dispatch_queue_create
或者系统提供的标准dispatch queue。
1 | // 生成一个serial dispatch queue |
dispatch_async(queue, block);
参数中的queue可以通过dispatch_queue_create
或者系统提供的标准dispatch queue。1 | // 生成一个serial dispatch queue |
创建plist文件及添加数值
数据读取,注意因为plist创建的时候可以选择dictionary或者array,这个也决定了后面怎么去读取它。
1 | NSString* filePath = [[NSBundle mainBundle] pathForResource:@"dict_data" ofType:@"plist"]; |
目前在8.0以后的推送需要以下几个步骤:
1.使用registerUserNotificationSettings: & registerForRemoteNotifications方法
1 | if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerForRemoteNotifications)]) { |
关于registerForRemoteNotifications方法有以下说明,它会需要实现两个delegate方法,并且方法能够被执行的条件是通过registerUserNotificationSettings:方法成功注册用户的notification,或者enabled for Background App Refresh。
// Calling this will result in either application:didRegisterForRemoteNotificationsWithDeviceToken: or application:didFailToRegisterForRemoteNotificationsWithError: to be called on the application delegate. Note: these callbacks will be made only if the application has successfully registered for user notifications with registerUserNotificationSettings:, or if it is enabled for Background App Refresh
2.实现delegate方法:每个APP都不同,就不写了。
1 | #if __LP64__ || (TARGET_OS_EMBEDDED && !TARGET_OS_IPHONE) || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64 |
Update your browser to view this website correctly. Update my browser now