解析XCode學(xué)習(xí)技巧
XCode學(xué)習(xí)技巧是本文要介紹的內(nèi)容,通過本文的學(xué)習(xí),可以從中方便、快速的去了解xcode幾個(gè)小案例的實(shí)現(xiàn)和使用方法,先來看詳細(xì)內(nèi)容。
1、更改公司名稱 (Changing the Company Name)
改變公司名稱, 當(dāng)你用Xcode新建一 Objective C 源文件的時(shí)候, 通常Xcode會自動生成底下的注釋:
- //
- // TapDance.h
- // Groovilicous
- //
- // Created by markd on 7/25/08.
- // Copyright 2008 __MyCompanyName__. All rights reserved.
- //
markd 是你登錄Mac系統(tǒng)的名字
__MyCompanyName__ 是你定義的公司名字, 可以通過以下命令在Terminal里面進(jìn)行修改名字:
- 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
縮進(jìn)
先選擇一段要編輯的內(nèi)容,用鼠標(biāo)拖動選擇好后:
- Command(win鍵盤的Alt) + [ 左縮進(jìn)
- Command + ] 右縮進(jìn)
- 右鍵 -> Re-Indent Selection 自動編排格式
代碼自動完成
Xcode會記住很多已經(jīng)存在的名字, 你鍵入字符的時(shí)候, 它會根據(jù)自己的字典來猜測你要寫的內(nèi)容, 如果匹配成功, 直接敲Tab鍵或者回車鍵Xcode就幫你完成剩余的內(nèi)容. Escape會列出一個(gè)下拉列表, 讓你自己有更多的選擇. ctrl+/ 來定位函數(shù)的多個(gè)占位符參數(shù).
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 打開快照管理器, 可以恢復(fù)之前建立的快照.
(2)查找(Find)
Edit -> Find
3、編輯在作用域中同名變量(Edit all in Scope)
選擇要編輯的名稱
- Edit -> Edit all in Scope
4、重構(gòu)(Refactor)
當(dāng)你重命名一個(gè)類的名字的時(shí)候, 相應(yīng)的文件名也被Rename. 這個(gè)功能很好用. Eclipse 有這種功能, VC的VA插件也有, 不過好像它們都不能重名文件名.
選擇要重命名的類名, 函數(shù)名等
- Edit -> Refactor
注釋: 很多命令有快捷鍵, 可以利用快捷鍵加快效率, 沒用快捷鍵的, 可以在Perferences里的key buildings設(shè)置命令對應(yīng)的快捷鍵.
5、Navigating Around in Your Code
下面的快捷鍵不僅僅是適用于Xcode, 而且適用諸如TextEdit, Safari's URL bar 等等, 一般具有編輯功能的都有這張功能(在Mac中)
ctrl + A 將光標(biāo)移動到當(dāng)前光標(biāo)所在行的開始位置
ctrl + E 將光標(biāo)移動到當(dāng)前光標(biāo)所在行的結(jié)束位置
ctrl + T 交換當(dāng)前光標(biāo)所在為止的詞和此詞的上一個(gè)詞的位置.(就是互換倆個(gè)詞)
ctrl + K 刪除當(dāng)前光標(biāo)所在位置到當(dāng)前行結(jié)尾處
ctrl + D 相當(dāng)于鍵盤的Delete按鍵, 刪除后面一個(gè)字符.
6、書簽(Bookmarks)
Edit -> Add Bookmarks (Alt + D)
In the Groups & Files pane, 你能找到Bookmarks, 里面的你可以點(diǎn)擊.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
小結(jié):解析XCode學(xué)習(xí)技巧的內(nèi)容介紹完了,希望通過本文的學(xué)習(xí)對你有所幫助!