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

< 前ページ次ページ >

プロパティを使ったサブクラス化

readonlyプロパティをオーバーライドして、これを書き込み可能にすることができます。たとえば、readonlyプロパティ、valueを持つMyIntegerというクラスを定義できます。

@interface MyInteger : NSObject
{
    NSInteger value;
}
@property(readonly) NSInteger value;
@end
 
@implementation MyInteger
@synthesize value;
@end

その後、このプロパティを書き込み可能にするように再定義する、サブクラスMyMutableIntegerを実装できます。

@interface MyMutableInteger : Integer
@property(readwrite) NSInteger value;
@end
 
@implementation MyMutableInteger
@dynamic value;
 
- (void)setValue:(NSInteger)newX
{
    value = newX;
}
@end


< 前ページ次ページ >


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