登录
  • 欢迎访问 Sharezer Blog

GCD函数解析(栅栏、信号量、一次性、调度组)

本文由 简悦 SimpRead 转码, 原文地址 juejin.cn 之前的两篇文章对 GCD 队列和调度函数进行了解析。本文将继续讲解 GCD 里面一些使用率较低的函数的使用。 栅栏函数 我们在开发中经常会使用到并发队列+异步函数,来开启新线程去完成耗时任务,但这样的操作存在一个漏洞,耗时任务的执行会呈现无序性,从而淡化队列的概念,而在特定的情况下,个别任务执行的条件是前置任务完成。这种情况使用并发队列 + 异步函数是无法实现的,这时候就需要栅栏函数出马了。 使用dispatch_barrier_async添加的任务,会将队列里面的任务分成 3 部分,dispatch_barrier……继续阅读 »

sharezer 3周前 (04-01) 60浏览 0评论 0个赞

iOS中的HOOK技术

[TOC] 一、fishhook 1、介绍 fishhook 是 facebook 出品的一个开源库。利用 mach-o 文件加载原理,通过 rebind_symbols 函数修改__DATA Segment 的符号指针指向,来动态的 Hook C 函数。 2、主要信息 2.1、结构体 struct rebinding { const char *name; //函数名称 void *replacement; //新的函数地址 void **replaced; //保存原始函数地址变量的指针(通常要存储下来,在替换后的方法里调用) }; 2.2、主要接口 /* 交换方……继续阅读 »

sharezer 3年前 (2021-04-19) 1830浏览 0评论 0个赞

MacOS 终端命令记录

// 显示Mac隐藏文件 defaults write com.apple.finder AppleShowAllFiles YES // 隐藏Mac隐藏文件 defaults write com.apple.finder AppleShowAllFiles NO // 强制使用集显 sudo pmset -a GPUSwitch 0 // 强制使用独显 sudo pmset -a GPUSwitch 1 // 自动切换模式 sudo pmset -a GPUSwitch 2 // 修改Mac地址 sudo ifconfig en0 ether [mac地址] ……继续阅读 »

sharezer 5年前 (2019-07-17) 1828浏览 0评论 0个赞

CocoaPods国内镜像

国内Specs 清华大学镜像 https://mirrors.tuna.tsinghua.edu.cn/git/CocoaPods/Specs.git 上海大学镜像 https://mirrors.shu.edu.cn/CocoaPods (仅HTTP/HTTPS访问,不支持git拉取) https://mirrors.shu.edu.cn/mgit/Specs (仅git访问) https://git.shuosc.org/CocoaPods/Specs (均支持) 中国区镜像表项 git://cocoapodscn.com/Specs.git 使用方法 对于旧版的 CocoaPods 可以……继续阅读 »

sharezer 5年前 (2019-05-01) 5025浏览 0评论 0个赞

iOS获取照片EXIF信息

废话不多说,直接上代码。 let options = PHImageRequestOptions() options.version = PHImageRequestOptionsVersion.current; options.deliveryMode = PHImageRequestOptionsDeliveryMode.highQualityFormat; options.isSynchronous = true; let phImageManager = PHImageManager.default() phImageManager.requestImageData(for: phot……继续阅读 »

sharezer 5年前 (2018-12-02) 2263浏览 0评论 0个赞

AVFoundation Programming Guide(官方文档翻译)完整版中英对照

新博客: 完整版 - AVFoundation Programming Guide 分章节版: – 第 1 章:About AVFoundation - AVFoundation 概述 – 第 2 章:Using Assets - 使用 Assets – 第 3 章:Playback - 播放 – 第 4 章:Editing - 编辑 – 第 5 章:Still and Video Media Capture - 静态视频媒体捕获 – 第 6 章:Export - 输出 – 第 7 章:Time and Media Representations 时间和媒体表现 版权声明:本文为博主原创翻译……继续阅读 »

sharezer 5年前 (2018-11-23) 5591浏览 0评论 0个赞

Android&iOS一键分享

[TOC] Android与iOS不嵌入微信SDK的情况上发送一份文件给微信好友。 1. iOS 一键分享 let activityVC = UIActivityViewController(activityItems: ["需要分享文件asset" as Any], applicationActivities: nil) activityVC.popoverPresentationController?.sourceView = self.view self.present(activityVC, animated: true, completion: nil) 效果如……继续阅读 »

sharezer 5年前 (2018-11-23) 3116浏览 0评论 0个赞