//枚举类型NS_ENUM()
typedef NS_ENUM(NSInteger, LeftMenuTopItemType) {
LeftMenuTopItemMain,
LeftMenuTopItemShows,
LeftMenuTopItemSchedule
};
for (i=1; i++; i<=7)
for (i=1; i++; i<=NUM_DAYS_IN_WEEK)
@property (weak, nonatomic) IBOutlet UIButton *myBtn;
@property (copy, nonatomic) NSString *name;
switch (condition) {
case 1:
// ** fall-through! **
case 2:
// code executed for values 1 and 2
break;
default:
//代码
break;
}
CGRect frame = self.view.frame;
CGFloat x = CGRectGetMinX(frame);
CGFloat y = CGRectGetMinY(frame);
CGFloat width = CGRectGetWidth(frame);
CGFloat height = CGRectGetHeight(frame);
CGRect frame = CGRectMake(0.0, 0.0, width, height);
@interface AirPlane
+ (instancetype)airPlaneWithType:(AirPlaneType)type;
@end
- (instancetype)init {
self = [super init];
if (self) {
//代码
}
return self;
}
+ (instancetype)sharedInstance {
static id sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sharedInstance = [[self alloc] init];
});
return sharedInstance;
}
//普通常量
static const NSTimeInterval ANIMATION_DURATION = 0.3;
//外部常量
extern const NSTimeInterval TYANIMATION_DURATION;
//错误
[dic setObject:obj forKey:@"key"];
//正确
[dic setObject:obj ? obj:@"" forKey:@"key"];
//错误
[array addObject:obj];
//正确
if (obj) {
[array addObject:obj];
}
//错误
array[index];
//正确
if (array && index < array.count) {
array[index];
}
//宏定义
#define ANIMATION_DURATION 0.3
platform :ios, ‘8.0’
target "工程名" do
pod 'AFNetworking', '~> 3.0.4'
pod 'MBProgressHUD', '~> 0.9.2'
pod 'SDWebImage', '~>3.8'
pod 'MJRefresh', '~> 3.0.6'
pod 'MJExtension', '~> 3.0.9'
pod 'SDAutoLayout', '~> 2.1.1'
pod 'SDCycleScrollView', '~> 1.65'
pod 'TYAttributedLabel', '~> 2.6.1'
pod 'HCSStarRatingView', '~> 1.4.5'
pod 'IQKeyboardManager', '~> 4.0.5'
pod 'HMSegmentedControl', '~> 1.5.3'
pod 'TYAlertController', '~> 1.1.8'
pod 'SKTagView', '~> 0.9.2’
end