轉自 http://blog.kungfusoft.com/programming/iphone/topic-281.html在使用諸如NSLog, [NSString stringWithFormat:]之類的函數時,都是基於c/c++風格的字串格式化工作的.本來c/c++就沒怎麼用過,到iphone開發開發時摻合上NS系的對象,格式化輸出更是一頭的亂.看了一下Programming Guide for Cocoa的文檔,還是有比較詳盡的說明的,整理出來備查.格式定義The format
http://www.davidhamrick.com/2012/05/28/Adding-Properties-to-an-Objective-C-Category-Revisted.htmlIn my last post I wrote about adding properties to a category in objective-c. I have ended up using this feature quite a bit recently so I wrote a macro
http://www.davidhamrick.com/2012/02/12/Adding-Properties-to-an-Objective-C-Category.htmlLet’s say you have a category that needs to store some information. Unfortunately you can’t add an instance variable, but you can add something called an
objective-c中,當一個類使用到另一個類時,並且在類的標頭檔中需要建立被引用的指標時,一、#import和@class如下面代碼:A.h檔案#import "B.h"@interface A : NSObject { B *b;}@end為了簡單起見:A類是引用類,B類是被引用類,這裡先不考慮A類的實現檔案。通常引用一個類有兩種辦法:
demo代碼如下:數組排序有四種方法:1、基本排序方式:利用NSString中提供的compare方法進行排序,見demo的arraySort12、自訂compare在實體類中自訂compareStudent方法,實現排序邏輯3、利用block進行排序:sortedArrayUsingComparator4、進階排序方法利用排序描述器,自訂排序優先順序Book.h檔案:#import <Foundation/Foundation.h>@interface Book :
以下內容主要是學習《Effective Objective-C 2.0》所做的筆記,我所購買的原書為英文原版,由於自己英文水平有限,理解可能有疏漏原書購買地址:亞馬遜7、The System FrameworksItem 47: Familiarize Yourself with the System