定义结构和访问结构成员
struct 语句的格式如下:
struct [structure tag]
{
member definition;
member definition;
...
member definition;
} [one or more structure variables];
示例:声明 ThreeFloats 结构:
typedef struct {
float x, y, z;
} ThreeFloats;
@interface MyClass
- (void)setThreeFloats:(ThreeFloats)threeFloats;
- (ThreeFloats)threeFloats;
@end
使用参数 @threeFloats
发送消息 valueForKey:的 MyClass 实例将调用 MyClass 方法 threeFloats 并返回包含在 NSValue 中的结果。