私は実際に、この全体のポインタを参照して参照して参照解除することを理解していると思っていましたが、今は再び切り詰められます。バイト配列(参照渡し)のアイテムを整数値に比較する方法
typedef NS_ENUM (uint8_t, ControlCode) {
CC_NONE = 0x00,
CC_START = 0x01,
CC_END = 0x02,
};
- (void)testReferencingAnArray
{
uint8_t msgBytes[3];
msgBytes[0] = CC_START;
msgBytes[1] = 3;
msgBytes[2] = CC_END;
XCTAssertEqual(msgBytes[0], CC_START);//These three tests pass
XCTAssertEqual(msgBytes[1], 3);
XCTAssertEqual(msgBytes[2], CC_END);
uint8_t *msgBytes_pointer = msgBytes;
[self evaluate:&msgBytes_pointer];
}
- (void)evaluate:(uint8_t **)msgBytes_pointer
{
XCTAssertEqual(*msgBytes_pointer[0], CC_START); //Test passes
XCTAssertEqual(*msgBytes_pointer[1], 3);
//Test fails with ("<11>") is not equal to ("3")
XCTAssertEqual(*msgBytes_pointer[2], CC_END);
//Test fails with ("<00>") is not equal to ("<02>")
}
必要はありませんか? –
@FiddlingBitsそうだと思いますが、いいえ、http://stackoverflow.com/questions/30618860/pass-uint8-t-array-to-methodによるとはありません。 –
私は、evaluate:が配列へのポインタを期待することを明確にするためにコードを編集しました。参照で配列を渡すことはできますが、配列内の項目に対して比較を実行することはできません。 –