UInt8 の配列を操作する必要がありますが、これを正しく行う方法がわかりません...
これは私のコードです:
@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;
}
これは、このメソッドを呼び出して myBuffer を埋める方法です。
UInt8 myBuffer[10000];
[xxx read: myBuffer]; <- how to do this correctly ?????
これは同等の動作する 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でこのメソッドを呼び出す方法です:
byte[] myBuffer = new byte[10000];
int n = read(myBuffer);