#import <Foundation/Foundation.h>
/**
默认的范围是protected
**/
@interface Animal :NSObject
{
int age;
NSString * name;
}
-(void)run:(int)speed;
@end
@implementation Animal
-(void)run:(int)speed{
NSLog(@"我的速度是%d",speed);
}
@end
int main(int argc, const char * argv[]) {
Animal* animal=[Animal new];
animal.run:44;
return 0;
}
貌似调用一个有参的方法就错了。但是我记得好像可以调用无参的方法。是这样的吗?
天蓬老师2017-04-24 09:15:49
Are you asking how to call a parameterless method?
I was just shocked by Masonry's packaging. The chain call is done in one go, elegant! Perfect!
@interface TestObject : NSObject
@property (nonatomic, readonly) dispatch_block_t function;
@end
@implementation TestObject
- (dispatch_block_t)function
{
return ^{
NSLog(@"function run !");
};
}
@end
TestObject * obj = [[TestObject alloc] init];
obj.function();