//1、建立常量字串。
nsstring *astring = @"this is a string!";
//2、建立空字串,給予賦值。
nsstring *astring = [[nsstring alloc] init];
astring = @"this is a string!";
nslog(@"astring:%@",astring);
[astring release];
//3、在以上方法中,提公升速度:initwithstring方法
nsstring *astring = [[nsstring alloc] initwithstring:@"this is a string!"];
nslog(@"astring:%@",astring);
[astring release];
//4、用標準c建立字串:initwithcstring方法
char *cstring = "this is a string!";
nsstring *astring = [[nsstring alloc] initwithcstring:cstring];
nslog(@"astring:%@",astring);
[astring release];
//5、建立格式化字串:佔位符(由乙個%加乙個字元組成)
int i = 1;
int j = 2;
nsstring *astring = [[nsstring alloc] initwithstring:[nsstring stringwithformat:@"%d.this is %i string!",i,j]];
nslog(@"astring:%@",astring);
[astring release];
//6、建立臨時字串
nsstring *astring;
astring = [nsstring stringwithcstring:"this is a temporary string"];
nslog(@"astring:%@",astring);
nsstring *path = @"astring.text";
nsstring *astring = [[nsstring alloc] initwithcontentsoffile:path];
nslog(@"astring:%@",astring);
[astring release];
nsstring *astring = [[nsstring alloc] initwithstring:@"this is a string!"];
nslog(@"astring:%@",astring);
nsstring *path = @"astring.text";
[astring writetofile: path atomically: yes];
[astring release];
//用c比較:strcmp函式
char string1 = "string!";
char string2 = "string!";
if(strcmp(string1, string2) = = 0)
//isequaltostring方法
nsstring *astring01 = @"this is a string!";
nsstring *astring02 = @"this is a string!";
bool result = [astring01 isequaltostring:astring02];
nslog(@"result:%d",result);
//compare方法(comparer返回的三種值)
nsstring *astring01 = @"this is a string!";
nsstring *astring02 = @"this is a string!";
bool result = [astring01 compare:astring02] = = nsorderedsame;
nslog(@"result:%d",result);
//nsorderedsame 判斷兩者內容是否相同
nsstring *astring01 = @"this is a string!";
nsstring *astring02 = @"this is a string!";
bool result = [astring01 compare:astring02] = = nsorderedascending;
nslog(@"result:%d",result);
//nsorderedascending 判斷兩物件值的大小(按字母順序進行比較,astring02大於astring01為真)
nsstring *astring01 = @"this is a string!";
nsstring *astring02 = @"this is a string!";
bool result = [astring01 compare:astring02] = = nsordereddescending;
nslog(@"result:%d",result);
//nsordereddescending 判斷兩物件值的大小(按字母順序進行比較,astring02小於astring01為真)
//不考慮大 小寫比較字串1
nsstring *astring01 = @"this is a string!";
nsstring *astring02 = @"this is a string!";
bool result = [astring01 caseinsensitivecompare:astring02] = = nsorderedsame;
nslog(@"result:%d",result);
//nsordereddescending判斷兩物件值的大小(按字母順序進行比較,astring02小於astring01為真)
//如何判斷字串為空
nsstring *urlstring = [urlinput stringvalue];
if (!urlstring) else else
} }
convert nsstring to int
1 nsstring *anumberstring = @"123";
2 int i = [anumberstring intvalue];
convert int to nsstring
1 int anumber = 123;
2 nsstring *astring = [nsstring stringwithformat:@"%d", anumber];
Oracle data guard常用維護操作命令
data guard是oracle提供的一種高可用性解決方案,用於資料保護和容災,通過日誌同步來把資料及時傳送到備用節點,現總結一下data guard環境下常用的維護命令 1 在生產庫停止data guard操作 sql show parameter log archive dest sql al...
JavaWeb response物件常用操作
方式一response.setcontenttype contenttype 方式二response.setheader content type contenttype response.setcontenttype mime 的作用 讓伺服器告訴瀏覽器它傳送的資料屬於什麼檔案型別,使客戶端瀏覽器...
JavaWeb response物件常用操作
方式一response.setcontenttype contenttype 方式二response.setheader content type contenttype response.setcontenttype mime 的作用 讓伺服器告訴瀏覽器它傳送的資料屬於什麼檔案型別,使客戶端瀏覽器...