一、註釋的格式能夠經過將代碼段拖到xcode左下角的code snippet Library來造成本身的代碼格式。
①Xcode provides a bunch of these Code Snippets, which you can find by opening the Utilities View on the right of your window. Near the bottom, you'll find the Code Snippets Library, in addition to the File Template Library (which works similarly). Snippets can be broken down by platform (Mac OS X, iOS) or viewed all together. Look through the available snippets to see how they might save you from repetitive typing in your code. xcode
The provided snippets are useful, but the cause for my adoration stems from being able to add my own snippets to the library. I've found this to be incredibly useful. 緩存
-
Find some code you'd like to be a snippet and select it. 架構
-
Drag the selected code to the Snippet Library. app
-
Give it a title and optionally a summary. These are used when browsing through the Snippet Library list. iphone
-
Choose a completion shortcut to invoke this snippet. My preference is to use the same letter, repeated three times (ie ddd) because it's quick to type, and it's very unlikely to conflict with another completion symbol in my code. Not only does it avoid direct conflicts, but it also lets me filter down the list of suggestions quickly, so I can accept the completion as quickly as possible. ide
-
Chose a platform and language, and Completion scope (defaults to the current scope) which lets you choose when the completion shortcut will be available (it wouldn't make sense for your custom initializer method snippet to appear in an Objective-C @interface). 測試
-
Finally, you may wish to edit the snippet code you've added. The mini-editor is syntax highlighted for you, although unfortunately you can't invoke other snippet completion shortcuts here! Sometimes trying this causes Xcode to have an aneurism. ui
-
Bonus: If you'd like your own 「blue code bubbles」 to appear as part of your snippet, just type the following in your snippet: <#text in the bubble#> When the user invokes the shortcut for the snippet, the inserted text will contain any blue code bubbles you've included in the hash tags. They can be tabbed back and forth (that is, pressing tab will select the next bubble) and can be accepted by pressing Return. You'll see why these are useful in my examples. this
Snippets I find useful
Retain/Assign property: Completion shortcuts of rrr and aaa respectively. google
@property (nonatomic, retain) <#type#> *<#name#>; @property (nonatomic, assign) <#type#> <#name#>;
Synthesize for a Custom ivar name: Completion shortcut sss
@synthesize <#property#> = _<#propertyIvar#>;
Useful when you have a custom naming scheme for your instance variables (such as _ivar or mMemberVariable).
Class extension interface: Shortcut eee
@interface <#class name#> () @end
Pragma line and name: Shortcut ppp. This could alternatively be on one line. Also, when naming your mark label, write out the symbol name in full and it will be CMD+DoubleClickable, ie UITableViewDelegate methods instead ofTable view delegate methods
#pragma mark - #pragma mark <#Label#>
Define macro: Shortcut ddd. Xcode will autocomplete #define for you out of the box, but I find it slower and it doesn't create tabbable bubbles for you for both arguments. I find adding this snippet to be much more efficient.
#define <#name#> <#substitution#>
While code reuse is an incredibly important factor, there are some bits you just can't help but write over and over again. The Code Snippet library can seriously reduce the hassle of this.
②還能夠經過如下方式對代碼進行標記:
//MARK:
//TODO:
//FIXME:
//???:
二、當xcode中代碼沒法進行索引時
進入該目錄下,刪除對應工程文件索引目錄便可:open ~/Library/Developer/Xcode/DerivedData
三、測試環境能夠真機調試,release版本不能夠真機調試
進入這個目錄:~/Library/Developer/Xcode/DerivedData,將裏面的數據進行刪除,而後重啓xcode
四、修改程序的Bundle identifier可能會致使程序始終沒法啓動,一直處在attachApp,須要作的是將模擬器從新啓動就能夠了,和重啓xcode。
五、4.3.3xcode緩存問題很嚴重,應該屬於4.3的一個bug,修改的代碼運行起來始終沒有變化,重啓xcode以後發現以前修改的內容所有沒了(另外應該與頭文件的引入有問題,相互引用致使文件沒法找到目標代碼)
六、關於Architectures和Valid Architectures的設置
======================================
Architectures是你打算編譯出多少個不一樣架構的可執行文件來(由於Cocoa的一個應用裏面能夠包含多個針對不一樣架構的可執行文件)
Valid Architectures是說編譯出來的可執行文件能夠在哪些架構的設備上運行,
最終會編譯出來多少個可執行文件取決於這兩個選項的交集。
因此,若是Architectures設定爲armv6,那麼無論 Valid Architectures 裏面設多少個其餘架構,最終都只會生成一個armv6版本的可執行文件。可是,若是Valid Architectures裏面沒有armv7的話,那麼編譯出來的可執行文件將不能在armv7的設備上運行,因此,當你裝到3GS之後的armv7設備上時,會報那個錯:沒法在選中的設備上運行。
具體到這個項目,由於大智慧的代碼編譯成 armv7 就會崩潰,因此只能編譯armv6版本,即把Architectures設成armv6這惟一一個值。可是,由於ARM架構是向下兼容的,即新架構的CPU能夠運行舊架構的代碼,而咱們也願意讓編出來的armv6版本能夠在新的armv7設備上運行,因此,Valid Architectures裏面應該包括 armv6, armv7, armv7s, i386。這個設置固定下來便可,之後不要每次修改。
ARMv7s = iPhone 5, iPad 4
ARMv7 = iPhone 3GS, iPhone 4, iPhone 4S, iPod 3G/4G/5G, iPad, iPad 2, iPad 3, iPad Mini
ARMv6 = iPhone 2G/3G, iPod 1G/2G
i386 = 模擬器
從Xcode 4.5開始,不支持編譯armv6的可執行文件了。因此要想支持armv6,必須用4.5以前的版本。但4.5以前的版本沒有iOS 6 SDK。
再順便說一下Build Active Architecture Only 這個選項。
所謂Active Architecture,就是當前插在你電腦上的,而且你在Xcode裏面選中了的那個設備的架構。
這個選項主要是給開發階段用的,由於假設你的應用須要出編譯好幾個架構的可執行文件,那麼每次編譯時間就比較長。可是調試的時候,其實只要編譯你用來調試的那臺機器的架構就夠了,其餘的都是浪費時間。因此,你能夠在開發用的target裏把這個選項設成Yes,最終用來打包的target裏設成No。這樣能夠提升效率。
==============================================================
七、出現Undefined symbols for architecture i386錯誤
①要麼在compile source 中沒有引入文件。
②要麼在link Binary中沒有引入應該引入的類庫。
PS:stackOverFlowhttp://stackoverflow.com/questions/6984368/undefined-symbols-for-architecture-i386-objc-class-skpsmtpmessage-refere
八、能夠經過給文件加編譯標籤來決定是否使用ARC
- -fno-objc-arc //不使用ARC
- -fobjc-arc //使用ARC
在compiler source中的compiler flags中加入以上字段