Equivalent of C++ STL container “pair” in Objective-C?

后端 未结 5 789
无人及你
无人及你 2021-02-13 03:34

I\'m new to Objective-C, so please don\'t judge me too much. I was wondering: Is there an equivalent of the C++ STL pair container I can use in Objective-C?

I want to bu

5条回答
  •  温柔的废话
    2021-02-13 04:09

    Using anonymous struct and struct literals, you might be able to do something like

    NSValue * v = [NSValue valueWithBytes:(struct {NSInteger i; bool b;}){i,b} objCType:(struct {NSInteger i; bool b;})];
    

    and then to read,

    struct {NSInteger i; bool b;} foo;
    [v getValue:&foo];
    

    It's a bit cleaner if you name your struct though.

提交回复
热议问题