我有这个方法可以调用另一个方法。如何将 char[] 传递给它而不是在其中包含 char[]?
- (IBAction)goThere(id)sender {
// char hex[] = {0xFF, 0xFF, 0x15}; <-- this is what I want to pass to elseWhere
// NSString *text = "some string"; <-- it would be cool to send other things too.
[self elseWhere];
}
- (void)elseWhere {
char hex[] = {0xDA, 0xFF, 0x15};
...
}
理想情况下,我能够从 goThere 发送 char[],能够根据需要重新使用 char[],不幸的是我在这方面并不先进。谢谢
最佳答案
试试这个:
-(IBAction)goThere:(id)sender {
char hex[] = {0xFF, 0xFF, 0x15};
[self elseWhereWithData:hex length:3];
}
-(void)elseWhereWithData:(char*)array length:(int)length {
// array is a char array with a length of length.
// Do stuff....strong text
}
关于Objective-C,如何将 char[] 传递给方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10866225/