第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

傳遞(UInt8數(shù)組的指針)和訪問(wèn)數(shù)組

傳遞(UInt8數(shù)組的指針)和訪問(wèn)數(shù)組

慕妹3242003 2019-03-14 14:15:04
目前正在做關(guān)于UInt8數(shù)組的相關(guān)應(yīng)用,遇到問(wèn)題。我的代碼:@interface MyClass : NSObject {     __strong id * myArray; //private byte[] myArray;  <- Java code } @property   (nonatomic,readwrite) __strong id * myArray; @end在MyClass中的方法:-(int) getArray: (__strong id *) bufferTmp {     NSString* aString = @"theString";     int bytes  = aString.length;     //now I need to fill the passed in array with the chars of the String     for (int i = 0; i < bytes; i++) {             char c = [aString characterAtIndex:i];             ??? bufferTmp[i] = (UInt8)c;   <----- what to write here?         } return bytes; }下面是我準(zhǔn)備調(diào)用方法充填myBuffer的代碼:UInt8 myBuffer[10000]; [xxx read: myBuffer];       <-      不知道這段正確么?這是相同的java代碼:public int getArray(byte[] bufferTmp) {     String theString = "theString";     for (int i = 0; i < bytes; i++) {         char c = theString.charAt(i);         bufferTmp[i] = (byte) c;         }      return bytes;  }在java中調(diào)用方法的代碼:byte[] myBuffer = new byte[10000];  int n = read(myBuffer);
查看完整描述

1 回答

?
千巷貓影

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊

在Objective-C中可以使用NSDate對(duì)象當(dāng)做byte buffer, 然后dataUsingEncoding獲取字節(jié)表示的字符串:

NSString *aString = @"theString";
NSData *myBuffer = [aString dataUsingEncoding:NSUTF8StringEncoding];

const char *bytes = [myBuffer bytes]; // pointer to the bytes in the buffer
NSUInteger count = [myBuffer length]; // number of bytes in the buffer


查看完整回答
反對(duì) 回復(fù) 2019-04-27
  • 1 回答
  • 0 關(guān)注
  • 515 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)