Time of Update: 2018-12-04
installed Xcode 4.6 and now facing with new errors in an ancient code I manage.the compiler now complains about "Direct access to objective-c's isa is deprecated in favor of object_setClass() and object_getClass()" and won't buildccessing isa has
Time of Update: 2018-12-04
堅持寫下日誌。printf和NSlog區別NSLog會自動加上分行符號,不需要自己添加分行符號,NSLog會加上時間和進程資訊,而printf僅將輸入的內容輸出不會添加任何額外的東西。兩者的輸入類型也是有區別的NSLog期待NSString*,而printf期待const char
Time of Update: 2018-12-04
@property簡介Objective-C語言關鍵詞,與@synthesize配對使用。功能:讓編譯器自動編寫一個與資料成員同名的方法聲明來省去讀寫方法的聲明。 如: 1、在標頭檔中: @property int count; 等效於在標頭檔中聲明2個方法: - (int)count; -(void)setCount:(int)newCount; 2、實現檔案(.m)中 @synthesize count; 等效於在實現檔案(.m)中實現2個方法。 - (int)c
Time of Update: 2018-12-04
深入理解Objective-c中@class的含義objective-c中,當一個類使用到另一個類時,並且在類的標頭檔中需要建立被引用的指標時, 如下面代碼: A.h檔案C代碼 #import "B.h" @interface A : NSObject { B *b; } @end 為了簡單起見:A類是引用類,B類是被引用類,這裡先不考慮A類的實現檔案。 通常引用一個類有兩種辦法:
Time of Update: 2018-12-04
//int代碼塊 int mutl =7; int (^visenBlock)(int) = ^(int num){return num *mutl;}; NSLog(@"%d",visenBlock(4)); //nsstring代碼塊 void (^visenPrintString)(NSString *str) = ^(NSString *str){ NSLog(@"print:%@", str); };
Time of Update: 2018-12-04
1、Objective-c調用js方法,只是需要調用uiwebview內建的方法就可以了。 [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"getHtmlString(‘%@’)",htmlStr]];2、js調用Objective-c方法,這時就需要和js約定一個參數或者方法了。- (BOOL)webView:(UIWebView *)webView
Time of Update: 2018-12-04
參考了<<C++編程規範 101條規則,準則與最佳實務>>1.匈牙利命名 和
Time of Update: 2018-12-03
最近學習了一下objective-c,對於新手,這個裡面加的東西是不是很不習慣啊,是不是會對@property @synthesize這個指令感到比較奇怪呢?畢竟C裡面沒有這個“亂七八糟“的東西啊!!首先介紹一下這個指令@property吧 這個“亂七八糟“的東西呢其實是一個很好的東西,如果你用很C的規範去寫一個類時,你會不會要對這個類的成員進行寫入和讀取資料呢?答案是必然的,所以這時你就得寫一個-(void) setX(id ..) 和一個-(id) X
Time of Update: 2018-12-04
1.第1章啟程本書除了介紹Objective-C語言,還會介紹蘋果公司為其提供的工具包Cocoa(針對OS X系統)和Cocoa
Time of Update: 2018-12-04
第6章
Time of Update: 2018-12-04
最近遇到這樣一個問題,以前的時候並未注意;建立一個工程,然後添加一個類,檔案結構是這樣的然後寫了這樣一小段程式,運行- (void)viewDidLoad{ [super viewDidLoad]; Test *testObj = [[Test alloc] init]; NSLog(@"release 前 %d",[testObj retainCount]); [testObj release]; NSLog(@"release 後
Time of Update: 2018-12-04
Apple在C,Objective-C和C++中擴充了Block這種文法的,並且在GCC4.2中進行了支援。現在我們可以在Mac 10.6和iOS 4中使用。如果是Mac 10.6 或 iOS 4.0 之前的平台,據說可以用http://code.google.com/p/plblocks/這個項目來支援Block文法。Apple在 Snow Leopard中所用到的Grand Central Dispatch(GCD)就是基於Blocks實現的。Grand Central
Time of Update: 2018-12-04
1 id cattle[3]; 2 SEL say; 3 SEL skin; 其中id
Time of Update: 2018-12-04
isKindOfClass: Returns a Boolean value that indicates whether the receiver is an instance of given class or an instance of any class that inherits from that class.isMemberOfClass: Returns a Boolean value that indicates whether the receiver is an
Time of Update: 2018-12-04
Class類型 到目前為止,我們已經知道了對應於方法的SEL資料類型,和SEL同樣在Objective-C裡面我們不僅僅可以使用對應於方法的SEL,對於類在Objective-C也為我們準備了類似的機制,Class類型。當一個類被正確的編譯過後,在這個編譯成功的類裡面,存在一個變數用於儲存這個類的資訊。我們可以通過一個普通的字串取得
Time of Update: 2018-12-04
本人翻譯的Apple Dev Center的技術資料並稍作修改。轉載請註明出處:http://blog.csdn.net/zhyzh2046/學習Objective-C:初級讀本Objective-C是一種簡單的電腦語言,支援複雜南通的物件導向編程。Objective-C從標準的ANSI
Time of Update: 2018-12-04
方法調用(Calling Methods)1. 調用 [object method]; [object methodWithInput:input]; 2.傳回值:output = [object methodWithOutput]; output = [object methodWithInputAndOutput:input];3.建立對象調用id myObject = [NSString string];NSString* myString = [NSString
Time of Update: 2018-12-04
以下筆記參考網站:http://blog.csdn.net/huanglx1984/archive/2009/07/06/4325377.aspx目前好象只有Apple使用Objective-C作為其支援的語言吧。與C++的不同之處有:O-C中所有的類都必須繼承自NSObject。O-C中所有對象都是指標的形式。O-C用self代替this。O-C使用id代替void*。O-C使用nil表示NULLO-Ck只支援單繼承。O-C使用YES/NO表示TRUE/FALSEO-C使用#import代替#
Time of Update: 2018-12-04
討論Objective-C的一個奇怪的概念 meta-class在Objective-C中的每個類,都有它自己相關的meta-class,但因為你很少直接使用meta-class,所以顯得很神秘。在運行時建立一個類下面的代碼在運行時建立一個NSError新的子類,並添加一個方法到裡面: Class newClass = objc_allocateClassPair([NSError class], “RuntimeErrorSubclass”,
Time of Update: 2018-12-04
Block Apple 在C, Objective-C, C++加上Block這個延申用法。目前只有Mac 10.6 和iOS 4有支援。Block是由一堆可執行的程式組成,也可以稱做沒有名字的Function (Anonymous function)。如果是Mac 10.6 或 iOS 4.0 之前的平台可以利用 http://code.google.com/p/plblocks/ 這個project得以支援Block語法。Apple有一個叫做GCD(Grand Central