Skip to content

Instantly share code, notes, and snippets.

@period331
Created December 9, 2014 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save period331/cd268e049616a762dfc5 to your computer and use it in GitHub Desktop.
Save period331/cd268e049616a762dfc5 to your computer and use it in GitHub Desktop.
property.m
#import <Foundation/Foundation.h>
@interface FKFruit : NSObject
@property(nonatomic, assign) double weight;
@property(nonatomic, assign) int a;
-(void) info;
@end
@implementation FKFruit
-(void)info
{
NSLog(@"Fruit!!!, weight: %f, a: %d", _weight, self.a);
}
-(void)setA:(int)aa
{
_a = aa; //这样为什么正确
// self.a = aa; //这样为什么错误
}
@end
@interface FKApple : FKFruit
@end
@implementation FKApple
-(void)info
{
[super info];
NSLog(@"Apple");
}
@end
int main (int argc, char * argv[])
{
@autoreleasepool {
FKApple * apple = [[FKApple alloc] init];
apple.weight = 100;
apple.a = 1009;
[apple info];
}
}
clang -fobjc-arc -framework Foundation propery.m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment