1.nsstring轉nsnumber
使用情景:coredata儲存資料,其中乙個為**,coredata裡面定義為float
用文字輸入框得到的資料型別是nsstring,將nsstring轉換成nsnumber方法:
detail.price = [nsnumber numberwithfloat:[self.pricetf.text floatvalue]];還有其他的轉換函式,如
1、字串拼接
nsstring *newstring = [nsstring stringwithformat:@"%@%@",tempa,tempb];
2、字串轉int
int intstring = [newstring intvalue];
3、int轉字串
nsstring *stringint = [nsstring stringwithformat:@"%d",intstring];
4、字串轉float
float floatstring = [ newstring floatvalue];
5、float轉字串
nsstring *stringfloat = [nsstring stringwithformat:@"%f",intstring];
iOS資料型別轉換。
一 基本資料與字串之間轉換。nsstring tempa 123 nsstring tempb 456 1,字串拼接 nsstring newstring nsstring stringwithformat tempa,tempb 2,字元轉int int intstring newstring i...
iOS 資料型別之間的轉換
在編碼過程中,資料的處理是必要的。眾多資料中,nsstring nsdata nsarray nsdictionary等資料型別是常用的,對付它們容易,但是在多個資料型別之間轉換,就需要技巧啦。可能不全面,根據lz本身專案需求,一直在新增,望給大家提供方便 在編碼過程中,資料的處理是必要的。眾多資料...
C 中資料型別轉換
1 使用parse方法 該方法只能將字串型別轉換成其他資料型別,語法格式 資料型別.parse string 資料型別可以是 int16,int32,int64,double,float,char,datetime中的任一種。2 使用convert方法 可以把任意型別轉換成其他型別,語法格式 con...