定義結構和訪問結構成員

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 中的結果。