解析XCode学习技巧

移动开发 iOS
本文主要是来学习Xcode的技巧,通过本文的学习,可以从中方便、快速的去了解xcode几个小案例的实现和使用方法,先来看详细内容。

XCode学习技巧是本文要介绍的内容,通过本文的学习,可以从中方便、快速的去了解xcode几个小案例的实现和使用方法,先来看详细内容。

1、更改公司名称 (Changing the Company Name)

改变公司名称, 当你用Xcode新建一 Objective C 源文件的时候, 通常Xcode会自动生成底下的注释:

  1. //  
  2. // TapDance.h  
  3. // Groovilicous  
  4. //  
  5. // Created by markd on 7/25/08.  
  6. // Copyright 2008 __MyCompanyName__. All rights reserved.  
  7. // 

markd 是你登录Mac系统的名字

__MyCompanyName__ 是你定义的公司名字, 可以通过以下命令在Terminal里面进行修改名字:

  1. defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{"ORGANIZATIONNAME" = "Length-O- Words.com";}'  
  2. Length-O- Words.com 

就是定义新的公司名称, 你可以自己替换自己要定义的名称.

2、Writing Your Code with a Little Help from Xcode

缩进

先选择一段要编辑的内容,用鼠标拖动选择好后:

  1. Command(win键盘的Alt) + [    左缩进  
  2.  
  3. Command + ] 右缩进  
  4.  
  5. 右键 -> Re-Indent Selection 自动编排格式 

代码自动完成

Xcode会记住很多已经存在的名字, 你键入字符的时候, 它会根据自己的字典来猜测你要写的内容, 如果匹配成功, 直接敲Tab键或者回车键Xcode就帮你完成剩余的内容. Escape会列出一个下拉列表, 让你自己有更多的选择. ctrl+/ 来定位函数的多个占位符参数.

Kissing the Parentheses(括号配对)

Xcode 可以自动配对括号, 而且回自动高亮显示.

  1. Double click one of the delimeters(")", "]", "}"), and Xcode will select the code between it and its mate. 

Mass Edit(批量编辑)

(1)快照(Snapshot)

  1. File -> Make Snapshot 建立快照  
  2. File -> Snapshots  打开快照管理器, 可以恢复之前建立的快照. 

(2)查找(Find)

Edit -> Find

3、编辑在作用域中同名变量(Edit all in Scope)

选择要编辑的名称

  1. Edit -> Edit all in Scope 

4、重构(Refactor)

当你重命名一个类的名字的时候, 相应的文件名也被Rename. 这个功能很好用. Eclipse 有这种功能, VC的VA插件也有, 不过好像它们都不能重名文件名.

选择要重命名的类名, 函数名等

  1. Edit -> Refactor 

注释: 很多命令有快捷键, 可以利用快捷键加快效率, 没用快捷键的, 可以在Perferences里的key buildings设置命令对应的快捷键.

5、Navigating Around in Your Code

下面的快捷键不仅仅是适用于Xcode, 而且适用诸如TextEdit, Safari's URL bar 等等, 一般具有编辑功能的都有这张功能(在Mac中)

ctrl + A    将光标移动到当前光标所在行的开始位置

ctrl + E    将光标移动到当前光标所在行的结束位置

ctrl + T    交换当前光标所在为止的词和此词的上一个词的位置.(就是互换俩个词)

ctrl + K    删除当前光标所在位置到当前行结尾处

ctrl + D    相当于键盘的Delete按键, 删除后面一个字符.

6、书签(Bookmarks)

Edit -> Add Bookmarks (Alt + D)

In the Groups & Files pane,   你能找到Bookmarks, 里面的你可以点击.Xcode Keyboard Shortcuts

  1. ⌘ 表示: Command(Alt)  
  2. ⇧表示: Shift  
  3. ⌥ 表示: Win  
  4. Control表示:Ctrl  
  5. Keystroke                      Description  
  6. ⌘⇧E                             Expand the editor  
  7. ⌘[                                  Shift the code block to the left  
  8. ⌘]                                  Shift the code block to the right  
  9. Tab                                Accept a completion  
  10. Esc                                Show the completion menu  
  11. Control-.                        (period) Cycle through the completions  
  12. Shift-control-.                (period) Cycle backward through the completions  
  13. Control-/                        Move to the next completion placeholder  
  14. Command-control-S    Make a snapshot  
  15. Control-F                     Move the cursor forward  
  16. Control-B                       Move the cursor backward  
  17. Control-P                   Move the cursor to the previous line  
  18. Control-N                   Move the cursor to the next line  
  19. Control-A                       Move the cursor to the beginning of the line  
  20. Control-E                   Move the cursor to the end of the line  
  21. Control-T                 Transpose the characters adjacent to the cursor  
  22. Control-D                 Delete the character to the right of the cursor  
  23. Control-K                 Delete the line  
  24. Control-L                 Center the cursor in the text editor  
  25. ⌘⌥D                          Show the Open Quickly window  
  26. ⌘⌥↑                                 Open the counterpart file  
  27. ⌘D                                 Add a bookmark  
  28. Option–double-click                 Search in documentation  
  29. ⌘Y                                 Run the program with the debugger  
  30. ⌘⌥P                                 Continue (in the debugger)  
  31. ⌘⌥O                                 Step over  
  32. ⌘⌥I                                 Step into  
  33. ⌘⌥T                                 Step out  

小结:解析XCode学习技巧的内容介绍完了,希望通过本文的学习对你有所帮助!

责任编辑:zhaolei 来源: 互联网
相关推荐

2011-08-19 15:16:41

XCodeUserScripts脚本

2011-07-20 14:31:56

XCode User Scrip 脚本

2011-07-19 15:55:09

Xcode Interface Builder

2013-04-18 10:19:40

iOS开发Xcode调试

2011-08-08 17:05:02

XCode UserScript 脚本

2011-08-04 18:09:32

Xcode 技巧 文档

2011-08-10 14:00:22

XcodeUIWebView视频

2010-03-05 13:46:12

Android编程学习

2011-07-28 14:06:52

XCode XCode 3.2

2013-03-29 13:17:53

XCode调试技巧iOS开发

2012-05-21 10:13:05

XCode调试技巧

2011-08-18 10:17:21

Xcode4Xcode

2011-07-26 17:47:13

2014-03-12 09:52:17

XcodeCode Snippe

2011-07-25 15:42:38

Xcode Vim

2011-08-01 10:41:59

Xcode 条件编译

2011-08-01 09:26:51

Xcode Xcode 4 Instrument

2011-08-01 17:31:25

Xcode开发 Cocoa

2011-07-06 14:32:52

Mac XCode

2011-08-01 15:57:58

点赞
收藏

51CTO技术栈公众号