|
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Here are some of the new features I've noticed, what have I missed?
Dave
- Instance variables can have access control:
@interface MyClass : NSObject
{
@public
int public_var;
@private
int private_var;
@protected
int protected_var;
}- We have the syntax for properties, in both classes and protocols:
@interface MyClass : NSObject
@property int foo;
@property(getter=_getBaz,setter=_setBaz) float baz;
@end
@implementation MyClass
- (int)_getBaz { return baz; }
- (void)_setBaz: (float)newBaz { baz = abs(newBaz); }
@end
@protocol MyProtocol
@property(copies,readonly) NSString *bar;
@end
int main(void) {
MyClass *m = [MyClass new];
m.baz = -5.0;
printf("%f\n", m.baz); /* -> 5.0000 */
}
- Protocols can list required or optional methods:
@protocol MyProtocol @optional - (int)foo; @required - (void)bar: (int)arg; @end
- The syntax for foreach is pretty obvious, but here it is anyhow:
- To accomodate GC, fields can be weak:
@interface MyClass
{
__weak id some_var;
}
@endAttachment:
PGP.sig
Description: This is a digitally signed message part
_______________________________________________ Do not post admin requests to the list. They will be ignored. Objc-language mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
| Home | Archives | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2011 Apple Inc. All rights reserved.