Time of Update: 2018-07-21
1、NSString 轉換成NSDate NSString *dateStr = “2013-6-3 14:58:00”; NSDateFormatter *format=[[NSDateFormatter alloc] init]; [format setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; NSDate *date=[format dateFromString:dateStr];
Time of Update: 2018-07-23
買了本《learn objective-c on Mac》,一開始買來看起來還蠻薄的,250頁,看了後,發現語言都有很多共同的地方,新的特性都從C++和java類似過來,就是換了個名字,感覺看了以後感覺收穫蠻大,雖然只接觸了點皮毛。 1.C語言知識 2.瞭解了xcode使用 3.懂得了一些新文法和新特性。 ----------------------------------------------------------------------------------
Time of Update: 2018-07-23
按書上的例子敲了敲: #import <Foundation/Foundation.h>int main(int argc,const char *argv[]){ @autoreleasepool { //聲明檔案管理對象 NSFileManager
Time of Update: 2018-07-26
holydancer原創,如需轉載,請在顯要位置註明: 轉自holydancer的CSDN專欄,原文地址:http://blog.csdn.net/holydancer/article/details/7355833 在objective-c中,我們可以用new簡單的代替alloc
Time of Update: 2018-07-26
一、Nullability檢測的支援 1. 簡介 在以前的OC中,開發中經常會遇到 因為某個方法應該返回執行個體對象而實際返回了空導致應用崩潰,而 Nullability 的用處就在這,它可以提示開發人員做是否為空白的判斷的提示。在 iOS 9 中,提出了新的關鍵字 :nullable、nonnull、null_resettable、_Null_unspecified; 注意 : 上述的關鍵字只能修飾 OC 對象,不能修飾 基礎資料型別 (Elementary
Time of Update: 2018-07-26
轉自:http://stephen830.iteye.com/blog/1461354 如果一個對象的生命週期顯而易見,很容易就知道什麼時候該new一個對象,什麼時候不再需要使用,這種情況下,直接用手動的retain和release來判定其生死足矣。但是有些時候,想知道某個對象在什麼時候不再使用並不那麼容易。如果下面的代碼,看上去非常簡單: Sample.h類介面部分 #import < Foundation / Foundation.h
Time of Update: 2018-07-26
Objective-C 屬性特性(assign , retain , copy , readonly , readwrite , atomic , nonatomic)
Time of Update: 2018-07-18
Objective-C 類,執行個體成員,靜態變數,對象方法,類方法(靜態方法),對象, 一、類 在ios中,類的聲明和實現時分離的,也就是說不能寫在同一個檔案中,聲明放在 .h檔案中,實現放在 .m 檔案中。在實現檔案中引入 .h檔案,#import "xxx.h" 聲明一個類: #import
Time of Update: 2018-07-24
在Objective-C中,向nil發送訊息不會crash。 原因是在執行id objc_msgSend(id self, SEL op, ...) 方法時,如果self = nil,函數不執行任何有意義的操作而直接返回。 發送給nil對象的訊息的傳回值取決於方法的傳回型別: 如果方法的傳回值是一個對象指標,則返回nil。 如果方法的傳回值是普通資料類型的指標,返回的是NULL。
Time of Update: 2018-07-24
原文地址: java 的long 時間與objective-c的時間轉換 困擾筆者快一個月的java時間與objective-c時間轉換問題終於有解了,沒想到這麼簡單java時間/1000就是objective-c的時間了。 擴充一下NSDate [cpp] view plain copy @interface NSDate&
Time of Update: 2018-08-19
Block閉包是OC中比較進階的概念。我們通過簡單的代碼來理解一下: #import <UIKit/UIKit.h>#import "AppDelegate.h"//代碼塊的聲明;傳回值int,參數類型int、int;int (^max)(int,int);typedef void (^SayHello)();int main(int argc, char * argv[]) { //代碼塊的賦值; max = ^(int
Time of Update: 2018-08-19
可變數組比普通的數組更加靈活。在OC中的實現如下: #import <UIKit/UIKit.h>#import "AppDelegate.h"int main(int argc, char * argv[]) { NSMutableArray *arr = [[NSMutableArray alloc] init]; for (int i = 0; i < 100; i++) {
Time of Update: 2018-08-19
#import <UIKit/UIKit.h>#import "AppDelegate.h"int main(int argc, char * argv[]) { //類似Java中的Map,即索引值對; NSDictionary *dict = @{@"name":@"zhangsan",@"age":@23}; //列印出整個字典; NSLog(@"%@",dict);
Time of Update: 2018-08-19
對於NSString,還有很多實用的方法,比如:大小寫轉換,前尾碼的匹配,字串的拼接,格式化字串的等等。下面我們來看一下: #import <Foundation/Foundation.h>int main(int argc, const char * argv[]) { @autoreleasepool { char *str1 = "Hello"; NSString
Time of Update: 2018-07-21
標籤:lease link 整合開發 配置 debug argv 不同 block 裝包 一、IDE的安裝(Code::Blocks)我們選用Code::Blocks作為IDE,它的安裝包可以從
Time of Update: 2018-12-03
objective-c的categories(分類) 一,當你想要為某個class 新增methods,你通常會擴充(extend,即繼承)它。然而這不一定是個完美解法,特別是你想要重寫一個class 的某個功能,但你卻沒有原始碼時。Categories 允許你在現有的class 加入新功能,但不需要擴充它。Ruby 語言也有類似的功能。例子一:1,MyObjectCateName.h:#import <Foundation/NSObject.h>#import "MyObject.
Time of Update: 2018-12-03
中文難以表達原著的意思Method and Class AttributesObjective-C now supports some gcc attributes for Objective-C methods.Syntactically, attributes for a method follow the method's declaration,and attributes for a method parameter sit between the parameter type
Time of Update: 2018-12-03
http://www.infoq.com/cn/articles/wwdc2012-objective-c-new-feature今年2012的WWDC上,蘋果針對Objective-C和LLVM編譯器都做了重大改進,我們來看一看Objective-C增加了哪些新特性。1、方法順序無關Objective-C類由聲明檔案h和實現檔案m組成,所有的public方法都在h檔案中聲明,private方法可以寫在m檔案中,但是在早期的編譯環境中需要注意方法的順序,例如下面的代碼,在早期的編譯環境會給出警告
Time of Update: 2018-12-03
In later chapters we will look at how to install and use Objective-C on Windows and Linux systems for those that do not have access to Mac OS X. If you are planning to develop iPhone applications (or Mac OS X applications for that matter), however,
Time of Update: 2018-12-03
Objective-C中一些