PATH="${HOME}/.bin:${PATH}"
export PATH="/opt/homebrew/opt/ruby/bin:$PATH"
source ~/.bash_profile PATH="/opt/homebrew/opt/ruby/bin:$PATH"
[ -f /opt/homebrew/etc/profile.d/autojump.sh ] && . /opt/homebrew/etc/profile.d/autojump.sh
alias r='repo forall -c '
alias rg='repo forall -c git '
alias rs='repo status'
alias rga='repo forall -c git add .'
alias rgco='repo forall -c git checkout '
alias rgcb='repo forall -c git checkout -b '
alias rgc='repo forall -c git commit '
alias rgf='repo forall -c git fetch '
alias rgpl='repo forall -c git pull '
alias rgpu='repo forall -c git push '
alias rgs='repo forall -c git status '
alias rgl='repo forall -c git log '
alias rgcf='repo forall -c git checkout -f && git clean -df'
Xcode 的 Code Snippets 文件存放于 ~/Library/Developer/Xcode/UserData/CodeSnippets 目录,只要直接把 *.codesnippets 文件放到这个目录下(若没有则自己创建),重启 Xcode 即可生效。
cd ~/Library/Developer/Xcode/UserData/CodeSnippets
git clone https://github.com/jokan163/codeSnippets.git ./其中通用的 Code Snippets;
注意,Xcode 对每一段 Code Snippet 都有规定适用的语言(Objective-C、Objective-C++、Swift、...)和作用域(如 Class 的 Interface 定义内、Class 的 Implementation 内、方法体内、...),所以测试某段 Code Snippet 不生效时请注意你当前是否处于不匹配的位置。
NSObject
pa- 定义一个assign的 propertypar- 定义一个assign, readonly的 propertypc- 定义一个copy的 propertyps- 定义一个strong的propertypsr- 定义一个strong, readonly的propertypw- 定义一个weak的propertypwr- 定义一个weak, readonly的propertyload_once- 创建一个带dispatch_once的+load方法propertySwizzleAssign- 用swizzle的方式定义一个assign的propertypropertySwizzleCopy- 用swizzle的方式定义一个copy的propertypropertySwizzleStrong- 用swizzle的方式定义一个strong的propertypropertySwizzleWeak- 用swizzle的方式定义一个weak的propertysharedInstance- 为当前类创建一个实现单例功能的sharedInstance方法exchangeImplementation- 重写当前类的load方法并在其中用swizzle替换方法实现
Block
blockParameterInMethod- 声明一个用于 OC 方法参数的 blockblockParameterInFunction- 声明一个用于 C 函数参数的 blockblockproperty- 声明一个用于 property 的 blockblocktypedef- 用typedef定义一个 blockblockvar- 定义一个作为局部变量的 block
Method & Function
fnv- 定义一个返回值为void的方法fnv:- 定义一个返回值为void且带参数的方法fnblock- 定义一个返回值类型为 block 的方法fnv_handleEvent- 定义一个用于UIControl事件回调的方法fnv_longPress- 定义一个用于UILongPressGestureRecognizer的回调方法(你就不用每次都去拼写那个很长的手势名字了)fnv_pan- 定义一个用于UIPanGestureRecognizer的回调方法fnv_tap- 定义一个用于UITapGestureRecognizer的回调方法
UIView
setFrame- 为UIView设置framesizeThatFits- 为当前 view 创建sizeThatFits:方法layoutSubviews- 展开layoutSubviews方法updateConstraints- 展开updateConstraints方法getWidth- 展开CGRectGetWidth()getHeight- 展开CGRectGetHeight()getMinX- 展开CGRectGetMinX()getMinY- 展开CGRectGetMinY()addtarget- 调用UIControl addTarget:action:forEvents:方法setImageForButton- 为UIButton设置图片setTitleColorForButton- 为UIButton设置文字颜色setTitleForButton- 为UIButton设置文字
UITableView
initWithStyle- 展开initWithStyle:方法initWithStyleForCell- 展开UITableViewCell initWithStyle:reuseIdentifier:方法tableViewDelegate- 展开常用的几个UITableViewDelegate方法numberOfSectionsInTableView- 展开numberOfSectionsInTableView:方法numberOfRowsInSection- 展开tableView:numberOfRowsInSection:方法cellForRowAtIndexPath- 展开tableView:cellForRowAtIndexPath:方法heightForRowAtIndexPath- 展开tableView:heightForRowAtIndexPath:方法didSelectRowAtIndexPath- 展开tableView:didSelectRowAtIndexPath:方法
UICollectionView
collectionViewDelegate- 展开常用的几个UICollectionViewDelegate方法numberOfSectionsInCollectionView- 展开numberOfSectionsInCollectionView:numberOfItemsInSection- 展开collectionView:numberOfItemsInSection:cellForItemAtIndexPath- 展开collectionView:cellForItemAtIndexPath:sizeForItemAtIndexPath- 展开collectionView:layout:sizeForItemAtIndexPath:方法didSelectItemAtIndexPath- 展开collectionView:didSelectItemAtIndexPath:方法didDeselectItemAtIndexPath- 展开collectionView:didDeselectItemAtIndexPath:方法
UIViewController
initWithNib- 展开initWithNibName:bundle:方法loadView- 展开loadView方法viewDidLoad- 展开viewDidLoad方法viewWillAppear- 展开viewWillAppear:方法viewDidAppear- 展开viewDidAppear:方法viewWillDisappear- 展开viewWillDisappear:方法viewDidDisappear- 展开viewDidDisappear:方法viewDidLayoutSubviews- 展开viewDidLayoutSubviews:方法updateViewConstraints- 展开updateViewConstraints:方法addChildViewController- 在当前UIViewController里添加childViewControllerremoveFromParentViewController- 将childViewController从当前的UIViewController里移除
Other
pragma- 展开一个用于 Xcode 导航的#pragma mark -宏osif- 展开一个 @available(iOS xxx, *) 的 if 判断externRefInH- 在*.h文件里声明一个extern const的指针externRefInM- 在*.m文件里为一个extern const的指针赋值externValueInH- 在*.h文件里声明一个extern const的值变量externValueInM- 在*.m文件里为一个extern const的变量赋值static reference- 定义一个static的指针static- 定义一个static的值变量__weakSelf- 定义一个weak的self指针__strongSelf- 将weakSelf指针改为strong的self指针logCallStackSymbols- 用NSLog打出当前的方法调用栈信息timeConsuming- 展开一段用CACurrentMediaTime()来计算方法耗时的代码