iOS中内联函数的使用
程序员文章站
2024-03-20 22:32:34
...
1、函数定义
typedef struct { CGFloat fahrenheit; CGFloat celsius; } SOLTemperature; static inline SOLTemperature SOLTemperatureMake(CGFloat fahrenheit, CGFloat celsius) { return (SOLTemperature){fahrenheit, celsius}; }
2、使用示例
@interface ViewController : UIViewController
@property (assign, nonatomic) SOLTemperature currentTemperature;
@end
self.currentTemperature = SOLTemperatureMake(80.6f, 27.0f);
NSLog(@"%.2f--%.2f",self.currentTemperature.fahrenheit,self.currentTemperature.celsius);