Skip to content

Instantly share code, notes, and snippets.

@tomaszj
Created July 4, 2012 09:48
Show Gist options
  • Save tomaszj/3046420 to your computer and use it in GitHub Desktop.
Save tomaszj/3046420 to your computer and use it in GitHub Desktop.
Properties examples
// Situation 1:
// .h
@property (nonatomic, strong) YourObject *yourObject;
// .m
@synthesize yourObject;
// Situation 2:
// .h
@property (nonatomic, strong) YourObject *yourObject;
// .m
@synthesize yourObject = _yourObject;
// Situation 3:
// .h
{
YourObject *_yourObject;
}
@property (nonatomic, strong) YourObject *yourObject;
// .m
@synthesize yourObject = _yourObject;
// Situation 4:
// .h
{
YourObject *yourObject;
}
@property (nonatomic, strong) YourObject *yourObject;
// .m
@synthesize yourObject;
// Situation 5:
// .h
@property (nonatomic, strong) YourObject *yourObject;
// .m
@synthesize yourObject = _yourObject;
- (void)setYourObject:(YourObject *)yourObject {
_yourObject = yourObject;
}
// Situation 6:
// .h
@property (nonatomic, strong) YourObject *yourObject;
// .m
@synthesize yourObject = _yourObject;
- (YourObject *)yourObject {
return _yourObject;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment