Skip to content

Instantly share code, notes, and snippets.

@ashikahmad
Created January 2, 2014 10:14
Show Gist options
  • Save ashikahmad/8217276 to your computer and use it in GitHub Desktop.
Save ashikahmad/8217276 to your computer and use it in GitHub Desktop.
//
// category_file.h
@interface SomeClass (Private)
@property (nonatomic, assign) id newProperty;
@end
NSString * const kNewPropertyKey = @"kNewPropertyKey";
@implementation SomeClass (Private)
@dynamic newProperty;
- (void)setNewProperty:(id)aObject
{
objc_setAssociatedObject(self, kNewPropertyKey, aObject, OBJC_ASSOCIATION_ASSIGN);
}
- (id)newProperty
{
return objc_getAssociatedObject(self, kNewPropertyKey);
}
@end
// category_file.m
@interface MyClass : NSObject
@property (retain, readonly) float value;
@end
// Private extension, typically hidden in the main implementation file.
@interface MyClass ()
@property (retain, readwrite) float value;
@end
@interface MyClass : NSObject
- (float)value;
@end
@interface MyClass () {
float value;
}
- (void)setValue:(float)newValue;
@end
@implementation MyClass
- (float)value {
return value;
}
- (void)setValue:(float)newValue {
value = newValue;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment