看板 [ MacDev ]
討論串[問題] char to NSString
共 3 篇文章
首頁
上一頁
1
下一頁
尾頁

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者reon (Traveler)時間13年前 (2012/03/31 01:48), 編輯資訊
0
0
0
內容預覽:
我是覺得 程式寫成這樣很不直覺 @@. 我會這樣寫. Byte *p = (Byte *)[buf bytes];. NSString *str = [NSString stringWithFormat:@"%d",p[127]];. 如果怕值 out of bound 取一下[buf length

推噓1(1推 0噓 0→)留言1則,0人參與, 最新作者zonble (zonble)時間13年前 (2012/03/26 18:04), 編輯資訊
0
0
0
內容預覽:
試試看這樣. str = [NSString stringWithFormat:@"%d",. *(char *)[[buf subdataWithRange:NSMakeRange(127, 1)] bytes]];. --. zonble.net. cocoa.zonble.net. --.

推噓1(1推 0噓 4→)留言5則,0人參與, 最新作者heyshi (baw)時間13年前 (2012/03/25 17:25), 編輯資訊
0
0
0
內容預覽:
NSData *buf;. NSString *str;. Byte *p =(Byte*) [[buf subdataWithRange:NSMakeRange(127, 1)] bytes];. // p裡的值為 <0d> 想取出13的值. int charToDecimal = 0;. cha
(還有381個字)
首頁
上一頁
1
下一頁
尾頁