解析XCode學習技巧
XCode學習技巧是本文要介紹的內容,通過本文的學習,可以從中方便、快速的去了解xcode幾個小案例的實現和使用方法,先來看詳細內容。
1、更改公司名稱 (Changing the Company Name)
改變公司名稱, 當你用Xcode新建一 Objective C 源文件的時候, 通常Xcode會自動生成底下的注釋:
- //
- // TapDance.h
- // Groovilicous
- //
- // Created by markd on 7/25/08.
- // Copyright 2008 __MyCompanyName__. All rights reserved.
- //
markd 是你登錄Mac系統的名字
__MyCompanyName__ 是你定義的公司名字, 可以通過以下命令在Terminal里面進行修改名字:
- defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{"ORGANIZATIONNAME" = "Length-O- Words.com";}'
- Length-O- Words.com
就是定義新的公司名稱, 你可以自己替換自己要定義的名稱.
2、Writing Your Code with a Little Help from Xcode
縮進
先選擇一段要編輯的內容,用鼠標拖動選擇好后:
- Command(win鍵盤的Alt) + [ 左縮進
- Command + ] 右縮進
- 右鍵 -> Re-Indent Selection 自動編排格式
代碼自動完成
Xcode會記住很多已經存在的名字, 你鍵入字符的時候, 它會根據自己的字典來猜測你要寫的內容, 如果匹配成功, 直接敲Tab鍵或者回車鍵Xcode就幫你完成剩余的內容. Escape會列出一個下拉列表, 讓你自己有更多的選擇. ctrl+/ 來定位函數的多個占位符參數.
Kissing the Parentheses(括號配對)
Xcode 可以自動配對括號, 而且回自動高亮顯示.
- Double click one of the delimeters(")", "]", "}"), and Xcode will select the code between it and its mate.
Mass Edit(批量編輯)
(1)快照(Snapshot)
- File -> Make Snapshot 建立快照
- File -> Snapshots 打開快照管理器, 可以恢復之前建立的快照.
(2)查找(Find)
Edit -> Find
3、編輯在作用域中同名變量(Edit all in Scope)
選擇要編輯的名稱
- Edit -> Edit all in Scope
4、重構(Refactor)
當你重命名一個類的名字的時候, 相應的文件名也被Rename. 這個功能很好用. Eclipse 有這種功能, VC的VA插件也有, 不過好像它們都不能重名文件名.
選擇要重命名的類名, 函數名等
- 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
- ⌘ 表示: Command(Alt)
- ⇧表示: Shift
- ⌥ 表示: Win
- Control表示:Ctrl
- Keystroke Description
- ⌘⇧E Expand the editor
- ⌘[ Shift the code block to the left
- ⌘] Shift the code block to the right
- Tab Accept a completion
- Esc Show the completion menu
- Control-. (period) Cycle through the completions
- Shift-control-. (period) Cycle backward through the completions
- Control-/ Move to the next completion placeholder
- Command-control-S Make a snapshot
- Control-F Move the cursor forward
- Control-B Move the cursor backward
- Control-P Move the cursor to the previous line
- Control-N Move the cursor to the next line
- Control-A Move the cursor to the beginning of the line
- Control-E Move the cursor to the end of the line
- Control-T Transpose the characters adjacent to the cursor
- Control-D Delete the character to the right of the cursor
- Control-K Delete the line
- Control-L Center the cursor in the text editor
- ⌘⌥D Show the Open Quickly window
- ⌘⌥↑ Open the counterpart file
- ⌘D Add a bookmark
- Option–double-click Search in documentation
- ⌘Y Run the program with the debugger
- ⌘⌥P Continue (in the debugger)
- ⌘⌥O Step over
- ⌘⌥I Step into
- ⌘⌥T Step out
小結:解析XCode學習技巧的內容介紹完了,希望通過本文的學習對你有所幫助!


















