Xcode - 非 App Store 下载官方 Xcode 安装包方法
变更记录
序号
录入时间
录入人
备注
1
2016-09-28
Alfred Jiang
-
方案名称Xcode - 非 App Store 下载官方 Xcode 安装包方法
关键字Xcode \ dmg \ Xcode 安装包
需求场景
需要同时安装多个 Xcode 时
需要安装较老版本 Xcode 时
参考链接
CSDN - XCode 7.3.1(dmg) 官方直接下载地址(离线下载)(推荐)
Apple - Downloads for Apple Developers
详细内容当需要安装多个版本 Xcode 用于适配不同模拟器时,App Store 的唯一最新版往往难以满足需求,这时候需要进入苹果的开发者中心下载独立的安装包
Xcode 8
8.0 下载地址
Xcode 7
7.3.1 下载地址
7.0 下载地址
Xcode 6
6.4 下载地址
6.0.1 下载地址
更多苹果官方开发工具下载参考 Apple - Downloads for Apple Developers
效果图(无)
备注(无)
NSTimer - 解决 NSTimer 的循环引用问题导致的内存泄漏
变更记录
序号
录入时间
录入人
备注
1
2016-08-24
Alfred Jiang
-
方案名称NSTimer - 解决 NSTimer 的循环引用问题导致的内存泄漏
关键字NSTimer \ 循环引用 \ Retain Cycle \ 内存泄漏
需求场景
使用 NSTimer 造成对象无法释放,出现循环引用
参考链接
Why’s Blog - iOS 中的 NSTimer(推荐)
详细内容由于 NSTimer 中 target 对 self 对象的强引用,造成在 dealloc 方法中无法调用 invalidate;不调用 invalidate 永远不会进入 dealloc 方法,而不进入 dealloc 方法则永远不会调用 invalidate;为了解决这一问题,可以使用如下 category 中提供的方法初始化,避免了 NSTimer 中 target 对 self 对象的强引用,这样就可以在 dealloc 方法中正常调用 invalidate 了
NSTimer+Weak.h
12345678910111213#import <Foundati ...
Runtime - 使用 Aspects 实现 Method Swizzling 和 AOP 实践
变更记录
序号
录入时间
录入人
备注
1
2016-09-09
Alfred Jiang
-
方案名称Runtime - 使用 Aspects 实现 Method Swizzling 和 AOP 实践
关键字Runtime \ Method Swizzling \ Aspect Oriented Programming \ 面向切面编程
需求场景
利用 Method Swizzling 对系统方法进行替换和追加行为
参考链接
顾 鹏 - Method Swizzling 和 AOP 实践(推荐)
GitHub - steipete/Aspects
详细内容在 Objective-C 中, Aspect Oriented Programming (面向切面编程) 就是利用 Runtime 特性给指定的方法添加自定义代码。有很多方式可以实现 AOP ,Method Swizzling 就是其中之一。而且幸运的是,目前已经有一些第三方库可以让你不需要了解 Runtime ,就能直接开始使用 AOP 。
Aspects 就是一个不错的 AOP 库,封装了 Runt ...
Git - 常见错误与解决方案
变更记录
序号
录入时间
录入人
备注
1
2016-07-01
Alfred Jiang
-
1
2016-11-29
Alfred Jiang
-
方案名称Git - 常见错误与解决方案
关键字Git \ 常见错误 \ 解决方案
需求场景
使用 Git 时遇到的常见错误解决方案
参考链接(见详细内容)
详细内容1. error: The following untracked working tree files would be overwritten by checkout:12$ git clean -d -fx ""$ git checkout -f another-branch
2. fatal: Unable to create 'xxx/xxx/.git/index.lock': File exists.12# 解决办法:直接删除 index.lock 文件$ rm xxx/xxx/.git/index.lock
效果图(无)
备注(无)
语法 - 通过 registerDefaults 实现单次记录需求
变更记录
序号
录入时间
录入人
备注
1
2016-06-16
Alfred Jiang
-
方案名称语法 - 通过 registerDefaults 实现单次记录需求
关键字语法 \ NSUserDefaults \ registerDefaults \ 单次记录
需求场景
需要实现单次记录的需求场景,避免重复赋值与重复记录
参考链接
CSDN - iOS: NSUserDefaults issues
详细内容registerDefaults 方法调用时会先检查 NSUserDefaults 中是否已经存在相同的 Key ,如果存在则不会把其覆盖。该特性可以很好的用于记录单次运行的需求,当某 Key 已经被赋值后,避免重复赋值和多次赋值。
示例代码:
1234567891011121314151617181920212223// [NSUserDefaults standardUserDefaults] 不包含 TEST_KEYNSLog(@"Log 0 : %@",[[NSUserDefaults standardUserDefaults] ...
Git - 恢复被误删除分支
变更记录
序号
录入时间
录入人
备注
1
2016-05-26
Alfred Jiang
-
方案名称Git - 恢复被误删除分支
关键字Git \ 恢复删除分支 \ 强制删除 \ 分支恢复 \ 误删除
需求场景
用于恢复被误删除的 Git 分支
参考链接
Atlassian - How to restore a deleted branch(推荐)
详细内容
通过以下命令查看操作日志,获取需要恢复的递交 <sha>
1$ git log -g
通过以下命令恢复分支<branch>
1$ git checkout -b <branch> <sha>
如需要恢复<sha>(35787c7e277f13277aa493dbe053a70fbf47ebd3) 至 <branch>(recover_branch) ,执行命令如下
12345$ git log -gcommit 35787c7e277f13277aa493dbe053a70fbf47ebd3...$ git checkout -b r ...
NSString - 删除 NSString 中前后空格或回车符
变更记录
序号
录入时间
录入人
备注
1
2016-07-14
Alfred Jiang
-
方案名称NSString - 删除 NSString 中前后空格或回车符
关键字NSString \ 删除 \ 字符串 \ 首尾空格
需求场景
删除 NSString 中的前后空格或回车符
参考链接
NSString 去掉前后空格或回车符
详细内容123NSString *string = @" spaces in front and at the end ";NSString *trimmedString = [string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; NSLog(trimmedString);
效果图(无)
备注(无)
网络 - 使用 SimplePingHelper 在 iPhone / iPad 上 ping 指定服务器
变更记录
序号
录入时间
录入人
备注
1
2016-06-12
Alfred Jiang
-
方案名称网络 - 使用 SimplePingHelper 在 iPhone / iPad 上 ping 指定服务器
关键字网络 \ ping \ 检测服务器连接
需求场景
测试 ping 连接
参考链接
Chris Hulbert - How to ping a server in Objective-C / iPhone(推荐)
GitHub - chrishulbert/SimplePingHelper
Zubin’s Blog - 苹果示例源码阅读:SimplePing
详细内容1. 将 SimplePingHelper 相关代码引入工程2. 使用方法如下123456789101112- (void)tapPing { [SimplePingHelper ping:@"www.google.com" target:self sel:@selector(pingResult:)];} ...
手势 - 判断点击位置是否在某区域 ( View ) 内
变更记录
序号
录入时间
录入人
备注
1
2016-04-14
Alfred Jiang
-
方案名称手势 - 判断点击位置是否在某区域 ( View ) 内
关键字手势 \ 点击位置 \ 区域 \ UITapGestureRecognizer
需求场景
需要对手势操作的点击位置进行判断时
判断点击位置是否在某控件中时
参考链接(无)
详细内容判断 UITapGestureRecognizer 点击位置是否在 _viewTest 控件中
方法一:CGRectContainsPoint
123456- (void)touchMainViewGesture:(UITapGestureRecognizer *)gesture{ if (CGRectContainsPoint(_viewTest.bounds, [gesture locationInView:_viewTest])) { NSLog(@"_viewTest touched"); }}
方法二:*- (BOOL)pointI ...
UIEvent - iOS 事件拦截
变更记录
序号
录入时间
录入人
备注
1
2016-04-14
Alfred Jiang
-
方案名称UIEvent - iOS 事件拦截
关键字UIEvent \ 事件拦截 \ 捕获任意点击事件
需求场景
需要响应任意点击事件
需要接收任意交互事件信息
参考链接
博客园 - iOS事件拦截(实现触摸任意位置隐藏指定view)
详细内容#####1. 新建一个自定义的 MyApplication 继承自 UIApplication,在 MyApplication 中实现 *-(void)sendEvent:(UIEvent )event 方法
123456- (void)sendEvent:(UIEvent*)event { //接收 event 并发送通知 [[NSNotificationCenter defaultCenter] postNotificationName:NotificationMyApplicationSendEvent object:event]; [super sendEvent:event];} ...