Created
December 9, 2014 14:18
-
-
Save period331/cd268e049616a762dfc5 to your computer and use it in GitHub Desktop.
property.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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