java uint8array_传递(UInt8数组的指针)和访问数组

目前正在做关于UInt8数组的相关应用,遇到问题。

我的代码:@interface MyClass : NSObject {

__strong id * myArray; //private byte[] myArray;  

}

@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 

char c = [aString characterAtIndex:i];

??? bufferTmp[i] = (UInt8)c;   

}

return bytes;

}

下面是我准备调用方法充填myBuffer的代码:UInt8 myBuffer[10000];

[xxx read: myBuffer];       

这是相同的java代码:public int getArray(byte[] bufferTmp) {

String theString = "theString";

for (int i = 0; i 

char c = theString.charAt(i);

bufferTmp[i] = (byte) c;

}

return bytes;

}

在java中调用方法的代码:byte[] myBuffer = new byte[10000];

int n = read(myBuffer);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值