1

我有这个方法可以调用另一个方法。如何将 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[],不幸的是我在这方面并不先进。谢谢

4

2 回答 2

2

试试这个:

-(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
}
于 2012-06-02T21:57:52.317 回答
0

像这样:

-(void)method:(char[])array {
    //do something with array
}

?

于 2012-06-02T21:55:15.687 回答