内容简介:swift2.3转swift3的替换脚本,可以处理很多问题
find . -name *.swift | xargs perl -p -i -e ' /NSIndexPath/IndexPath/g '
find . -name *.swift | xargs perl -p -i -e ' s/NSIndexPath/IndexPath/g '
find . -name *.swift | xargs perl -p -i -e ' s/heightForRowAtIndexPath/heightForRowAt/g '
#
find . -name *.swift | xargs perl -p -i -e 's/CGRectMake/RectMake/g'
find . -name *.swift | xargs perl -p -i -e '
s/cellForRowAtIndexPath/cellForRowAt/g
'
find . -name *.swift | xargs perl -p -i -e ' s/forRowAtIndexPath/forRowAt/g '
find . -name *.swift | xargs perl -p -i -e ' s/didSelectRowAtIndexPath/didSelectRowAt/g '
find . -name *.swift | xargs perl -p -i -e ' s/cellForItemAtIndexPath/cellForItemAt/g '
find . -name *.swift | xargs perl -p -i -e ' s/shouldSelectItemAtIndexPath/shouldSelectItemAt/g '
find . -name *.swift | xargs perl -p -i -e ' s/didSelectItemAtIndexPath/didSelectItemAt/g '
find . -name *.swift | xargs perl -p -i -e ' s/\(_\:NSURLSessionDataTask\!\, resp\:AnyObject\!\)/\(_, resp\) /g '
find . -name *.swift | xargs perl -p -i -e ' s/\(_, rspObj:AnyObject!\)/\(_, resp\) /g '
find . -name *.swift | xargs perl -p -i -e ' s/\(_, resp:AnyObject\!\)/\(_, resp\) /g '
find . -name *.swift | xargs perl -p -i -e ' s/_:URLSessionDataTask!, responseObj:AnyObject!/_, responseObj/g '
find . -name *.swift | xargs perl -p -i -e ' s/\(_, error:NSError\!\)/\(_, error\)/g '
find . -name *.swift | xargs perl -p -i -e ' s/\(_:NSURLSessionDataTask!, error:NSError!\)/\(_, error\)/g '
find . -name *.swift | xargs perl -p -i -e ' s/func doAction\(_ action: String, model: AnyObject\!, fromView: UIView\?\)/func doAction\(_ action: String, model: Any\!, fromView: UIView\?\)/g '
find . -name *.swift | xargs perl -p -i -e ' s/CGPointZero/CGPoint.zero/g '
find . -name *.swift | xargs perl -p -i -e ' s/CGFloat.max/\CGFloat\.greatestFiniteMagnitude/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.NoData/\.noData/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.Fail/\.fail/g '
find . -name *.swift | xargs perl -p -i -e ' s/UIEdgeInsetsZero/UIEdgeInsets.zero/g '
#
autoPinEdgeToSuperviewEdge
find . -name *.swift | xargs perl -p -i -e '
s/\.autoPinEdgeToSuperviewEdge\(\.Leading/\.autoPinEdge\(toSuperviewEdge\: \.leading/g
'
find . -name *.swift | xargs perl -p -i -e ' s/\.autoPinEdgeToSuperviewEdge\(\.Trailing/\.autoPinEdge\(toSuperviewEdge\: \.trailing/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.autoPinEdgeToSuperviewEdge\(\.Bottom/\.autoPinEdge\(toSuperviewEdge\: \.bottom/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.autoPinEdgeToSuperviewEdge\(\.Top/\.autoPinEdge\(toSuperviewEdge\: \.top/g '
find . -name *.swift | xargs perl -p -i -e ' s/codecToInstance\(/codec\(toInstance:/g '
find . -name *.swift | xargs perl -p -i -e ' s/UIFont\.\.systemFont/UIFont\.systemFont/g '
下面这两句处理的是不同的函数
#find . -name *.swift | xargs perl -p -i -e 's/deselectRowAtIndexPath\(/deselectRow\(at:/g'
find . -name *.swift | xargs perl -p -i -e ' s/\.locationInView\(/\.location\( in:/g '
find . -name *.swift | xargs perl -p -i -e ' s/CGRectZero/CGRect.zero/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.dismissViewControllerAnimated\(/\.dismiss\(animated: /g '
find . -name *.swift | xargs perl -p -i -e ' s/LocalCache\.sharedCache\(\)\.cachedObjectForKey\(/LocalCache\.shared\(\)\.cachedObject\(forKey/g '
find . -name *.swift | xargs perl -p -i -e ' s/LocalCache\.shared\(\)\.cachedObject\(forKey/LocalCache\.shared\(\)\.cachedObject\(forKey\:/g '
find . -name *.swift | xargs perl -p -i -e ' s/willDisplayCell/willDisplay/g '
find . -name *.swift | xargs perl -p -i -e ' s/XRZPostLoadingView\.showSuccessfulWithTitle\(/XRZPostLoadingView\.showSuccessful\(withTitle\:/g '
#
这个地方改了以后需要尾部添加括号,需要手动搜索NotificationCenter.default.post(name:NSNotification.Name(rawValue出来修改
find . -name *.swift | xargs perl -p -i -e '
s/NSNotificationCenter\.defaultCenter\(\)\.postNotificationName\(/NotificationCenter\.default\.post\(name\:\ NSNotification.Name\(rawValue\: /g
'
find . -name *.swift | xargs perl -p -i -e ' s/\.showTextWithTitle\(/\.showText\(withTitle\:/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.showSuccessWithTitle\(/\.showSuccessful\(withTitle\:/g '
find . -name *.swift | xargs perl -p -i -e ' s/\(task\:URLSessionDataTask\!\,\ respon\:AnyObject\!\)/\(_\,\ respon\)/g '
find . -name *.swift | xargs perl -p -i -e ' s/\(_,\ reponseObj\:AnyObject\!\)/\(_\,\ respon\)/g '
find . -name *.swift | xargs perl -p -i -e ' s/\(_\:URLSessionDataTask\!\,\ responseObj\:AnyObject\!\)/\(_\,\ respon\)/g '
find . -name *.swift | xargs perl -p -i -e ' s/\(_, responseObj:AnyObject!\)/\(_, responseObj\)/g '
find . -name *.swift | xargs perl -p -i -e ' s/task:URLSessionDataTask!, error:NSError!/_, error/g '
find . -name *.swift | xargs perl -p -i -e ' s/\(task:URLSessionDataTask!, responseObj:AnyObject!\)/\(_, responseObj\)/g '
find . -name *.swift | xargs perl -p -i -e ' s/\(_\:URLSessionDataTask\!\,\ error\:NSError\!\)/\(_\,\ error\)/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.popToRootViewControllerAnimated\(/\.popToRootViewController\(animated: \/g '
find . -name *.swift | xargs perl -p -i -e ' s/removeAlert\(/let _ = removeAlert\(/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.addObject\(/\.add\(/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.rac_newValueChannelWithNilValue\(/\.rac_newValueChannel\(withNilValue:/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.NotMore/\.notMore/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.ChatRoom/\.chatRoom/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.Normal/\.normal/g '
find . -name *.swift | xargs perl -p -i -e ' s/MarkTableViewDD\.normal/MarkTableViewDD\.Normal/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.showFailWithTitle\(/\.showFail\(withTitle\:\ /g '
find . -name *.swift | xargs perl -p -i -e ' s/\.heightFromHitModel\(/\.height\(fromModel\:\ /g '
find . -name *.swift | xargs perl -p -i -e ' s/model\:AnyObject\!\,/model\:Any\!\,/g '
find . -name *.swift | xargs perl -p -i -e ' s/func\ heightForModel\(_\ model\:AnyObject\!\)->CGFloat/func\ heightForModel\(_\ model\:Any\!\)->CGFloat/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.showSuccessfulWithTitle\(/\.showSuccessful\(withTitle\:\ /g '
find . -name *.swift | xargs perl -p -i -e ' s/\.TouchUpInside\.touchUpInside/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.rac_signalForControlEvents\(/\.rac_signal\(for\:\ /g '
find . -name *.swift | xargs perl -p -i -e ' s/\UIEdgeInsetsZero/\UIEdgeInsets.zero/g '
find . -name *.swift | xargs perl -p -i -e ' s/\.systemFontOfSize\(/\..systemFont(ofSize:\ /g '
#find . -name *.swift | xargs perl -p -i -e 's/\.Normal/\.normal/g'
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- swift2.3转swift3的替换脚本,可以处理很多问题
- CSS 基础:块级元素、行内元素、替换元素、非替换元素
- Vim 中怎么将目标字符替换成新行以及如何替换换行符
- PowerShell正则替换实战
- 阿里开源软件替换指南
- 【译】逐步替换Sass
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
How to Think About Algorithms
Jeff Edmonds / Cambridge University Press / 2008-05-19 / USD 38.99
HOW TO THINK ABOUT ALGORITHMS There are many algorithm texts that provide lots of well-polished code and proofs of correctness. Instead, this one presents insights, notations, and analogies t......一起来看看 《How to Think About Algorithms》 这本书的介绍吧!