Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

< 前ページ次ページ >

プロパティのイントロスペクション

コンパイラはプロパティの宣言を見つけると、それを囲んでいるクラス、カテゴリ、プロトコルに関連付けられる説明用のメタデータを生成します。このメタデータにアクセスするには、クラスまたはプロトコルを対象とする名前によるプロパティ検索をサポートし、プロパティの型を@encode文字列として取得し、プロパティの属性のリストをC文字列の配列としてコピーする関数を使用します。各クラスとプロトコルには宣言されたプロパティのリストを使用できます。

Property構造体は、プロパティ記述子への不透過なハンドルを定義します。

typedef struct objc_property *Property;

関数class_getPropertyおよびprotocol_getPropertyは、それぞれクラスとプロトコルの中で名前付きプロパティを検索します。

Property class_getProperty(Class cls, const char *name);
Property protocol_getProperty(Protocol *proto, const char *name);

class_copyPropertyList関数とprotocol_copyPropertyList関数は、それぞれクラス内(読み込まれているカテゴリも含めて)とプロトコル内で宣言されたすべてのプロパティへのmallocされたポインタの配列を返します。

Property* class_copyPropertyList(Class cls, uint32_t *count);
Property* protocol_copyPropertyList(Protocol *protocol, uint32_t *count);

property_getInfo関数は、プロパティの名前と@encode型の文字列を返します。

void property_getInfo(Property *property, const char **name, const char **type);

property_copyAttributeList関数は、プロパティのコンパイル時の属性リストを表すC文字列へのmallocされたポインタの配列を返します。

const char **property_copyAttributeList(Property *property, unint32_t *count);


< 前ページ次ページ >


Last updated: 2007-10-31




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice