这篇文章主要是分享Mac上Xcode开发中的工作流程的小技巧
Markdown
Markdown是纯文本文档,却能图文并茂地显示文章;
不用过多地考虑排版问题,只要用对元素就行,专注在内容表达上,就能呈现美观易读的文章;
适合引用代码块,比如高亮与缩进
以下软件或网站都可以使用Markdown:
- Cmd Markdown 编辑阅读器
- iPic
- 简书
- GitHub
- MWeb
元素:标题,链接,图片,代码块,列表,表格......

快捷键
操作中使用快捷键可以提升工作效率,但记忆和发现快捷键是痛苦的,以下软件可以方便我们记忆:
比如下图,KeyCue显示的Finder的快捷键

Xcode
- User Breakpoints
- Open Quickly
- 文件内大纲
- 文件过滤
- 代码折叠
- 留白与区块
- 导航
- 数据库可视化
User Breakpoints

- 在UIApplicationMain上新建符号断点
- 在断点上增加
Action:Debugger Command
内容为expr (Class)NSClassFromString(@"IBARevealLoader") == nil ? (void *)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/RevealServer.framework/RevealServer", 0x2) : ((void*)0)
- 在普通断点上右击,选择
Move Breakpoints To
,选择User
Open Quickly
shift + command + o
模糊搜索,打开文件,打开函数,打开类,

打开函数 setupif

打开文件 cmplayer

模糊搜索 cmbpvc

文件内大纲
control + 6

文件过滤
最近查看/编辑过的文件
command + 1 --> option + command +j --> tab --> space
代码折叠
shift + option + command + <-
shift + option + command + ->
代码风格
id b = ^(){};
[self willTurnPageForward:b];
折叠代码后好复制移动代码,利于分区
留白与区块

关于VC中的Public方法,这里不讨论
关于private methods,正常情况下ViewController里面不应该写
不是delegate方法的,不是event response方法的,不是life cycle方法的,就是private method了。对的,正常情况下ViewController里面一般是不会存在private methods的,这个private methods一般是用于日期换算、图片裁剪啥的这种小功能。这种小功能要么把它写成一个category,要么把他做成一个模块,哪怕这个模块只有一个函数也行
ViewController基本上是大部分业务的载体,本身代码已经相当复杂,所以跟业务关联不大的东西能不放在ViewController里面就不要放。另外一点,这个private method的功能这时候只是你用得到,但是将来说不定别的地方也会用到,一开始就独立出来,有利于将来的代码复用
留白
#import <Foundation/Foundation.h>
@interface CMBatchDownloadManager : NSObject
@end
//留白:类与类之间有留白:2行或更多
@interface CMBatchTask : NSObject<NSURLSessionDelegate>
@property (nonatomic, copy, readonly)NSString* bookID;
@property (nonatomic, readonly)NSError* error;//下载任务下载错误原因
- (instancetype)initWithBookID:(NSString*)bookID
chapterList:(NSArray<NSString*>*)chapterList
formatType:(NSString*)formatType
isSupportRTF:(NSString*)isSupportRTF
clientAgent:(NSString*)clientAgent
userId:(NSString*)userId
url:(NSString*)url;
- (void)pause;//留白:- 与 返回类型之间有留白
- (void)resume;//留白:方法与方法之间有留白:1行
- (void)cancel;
@end
不留"白": 变量定义与第1次使用
//坏的示例
BOOL change = YES;
/*
.......其它代码
*/
if (![self hasPrevLeaf]) {
change = NO;
block();
return;
}
/*
.......其它代码
*/
BOOL change = YES;
if (![self hasPrevLeaf]) {
change = NO;
block();
return;
}
不留"白"
- (void)drawRect:(CGRect)rect
{
}
导航

数据库可视化
"journal_mode": 数据不会立即写入sqlite文件
NSMutableDictionary *sqliteOptions = [NSMutableDictionary dictionary];
[sqliteOptions setObject:@"WAL" forKey:@"journal_mode"];
cmread.sqlite
cmread.sqlite-shm
cmread.sqlite-wal
"DELETE": 数据立即写入sqlite文件
NSMutableDictionary *sqliteOptions = [NSMutableDictionary dictionary];
[sqliteOptions setObject:@"DELETE" forKey:@"journal_mode"];
cmread.sqlite
Git
git config
➜ ~ git config --system --help
usage: git config [<options>]
Config file location
--global use global config file
--system use system config file
--local use repository config file
-f, --file <file> use given config file
范围 | 文件 |
---|---|
--system | /etc/gitconfig |
--global | ~/.gitconfig |
--local | .git/config |
~/.gitconfig文件部分内容:
[core]
excludesfile = /Users/zhoujie/.gitignore_global
editor = /Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl -n -w
[difftool "sourcetree"]
cmd = /usr/local/bin/bcomp \"$LOCAL\" \"$REMOTE\"
path = -ro
[mergetool "sourcetree"]
cmd = /usr/local/bin/bcomp \"$LOCAL\" \"$REMOTE\" \"$BASE\" \"$MERGED\"
trustExitCode = true
[commit]
template = ~/.gitmessage
.git/config文件部分内容:
[difftool "tower"]
cmd = \"/Applications/Tower.app/Contents/Resources/beyondcompare.sh\" \"$LOCAL\" \"$REMOTE\"
~/.arcrc文件部分内容:
{
"config": {
"default": "http://211.140.17.116:8089/",
"editor": "/Applications/Sublime\\ Text.app/Contents/SharedSupport/bin/subl -n -w"
}
}
git rebase
git reset
git cherry-pick
git-cherry-pick - Apply the changes introduced by some existing commits
Alfred
阿尔弗雷德,电影《蝙蝠侠》里的管家


功能:
- 打开应用程序
- 打开文件
- 搜索 Web Search, File Search
- 剪切板
- 计算器



编辑器
- Atom
- Sublime Text
- Visual Studio Code
Visual Studio Code
的插件Code Runner
可以运行语言代码:

- 选择文件语言类型
- 写代码
-
运行
iTerm, FinderGo, OpenSim, Patterns
FinderGo: Open terminal quickly from Finder
OpenSim: OpenSim is an open source alternative to SimPholders, written in Swift.
Patterns: Patterns is a simple yet powerful tool for working with regular expressions. Build great patterns quickly and effortlessly with syntax coloring, and with matching and replacing occurring in real time
可以点击链接打开浏览器


- Regular Expression:
\[\d+:\d\d.\d+\]
- Search Text:
[00:00.10]
- 选择Objective-C复制代码后:
@"\\[\\d+?:\\d\\d.\\d+?\\]"//转意后的正则表达式
NSError *error = NULL;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"\\[\\d+?:\\d\\d.\\d+?\\]" options:0 error:&error];
NSUInteger numberOfMatches = [regex numberOfMatchesInString:searchText options:0 range:NSMakeRange(0, [string length])];
[TOC]
网友评论