|
| 1 | +// |
| 2 | +// Prefix header |
| 3 | +// |
| 4 | +// The contents of this file are implicitly included at the beginning of every source file. |
| 5 | +// |
| 6 | + |
| 7 | +#import <Availability.h> |
| 8 | + |
| 9 | +#ifndef __IPHONE_3_0 |
| 10 | +#warning "This project uses features only available in iOS SDK 3.0 and later." |
| 11 | +#endif |
| 12 | + |
| 13 | +#ifdef __OBJC__ |
| 14 | + #import <UIKit/UIKit.h> |
| 15 | + #import <Foundation/Foundation.h> |
| 16 | + #import <CoreData/CoreData.h> |
| 17 | + |
| 18 | + #import "APIUrl.h" |
| 19 | + |
| 20 | + #import "NSString+Common.h" |
| 21 | + #import "NSObject+Common.h" |
| 22 | + #import "UIImage+Common.h" |
| 23 | + #import "UIButton+Bootstrap.h" |
| 24 | + #import "UIColor+expanded.h" |
| 25 | + #import "UIButton+Common.h" |
| 26 | + #import "UITableView+Common.h" |
| 27 | + #import "UIView+Common.h" |
| 28 | + #import "UIImageView+Common.h" |
| 29 | + #import "UILabel+Common.h" |
| 30 | + #import "NSDate+Common.h" |
| 31 | + #import "UIBarButtonItem+Common.h" |
| 32 | + #import "UIActionSheet+Common.h" |
| 33 | + #import "NSURL+Common.h" |
| 34 | + #import "UITTTAttributedLabel.h" |
| 35 | + #import "NSObject+ObjectMap.h" |
| 36 | + #import "ImageSizeManager.h" |
| 37 | + #import "MobClick.h" |
| 38 | + #import <BlocksKit/BlocksKit+UIKit.h> |
| 39 | + #import <ReactiveCocoa/ReactiveCocoa.h> |
| 40 | + #import <ReactiveCocoa/RACEXTScope.h> |
| 41 | + #import "UIImageView+WebCache.h" |
| 42 | + #import <Masonry/Masonry.h> |
| 43 | + |
| 44 | + #import "BaseNavigationController.h" |
| 45 | + #import "BaseViewController.h" |
| 46 | + |
| 47 | +#endif |
| 48 | +//友盟统计 |
| 49 | +#define kUmeng_AppKey @"" |
| 50 | +#define kUmeng_Event_Request @"Request" |
| 51 | + |
| 52 | +//友盟推送 |
| 53 | +#define kUmeng_AppKey_Push @"" |
| 54 | +#define kUmeng_DeviceTokenKey @"Umeng_DeviceTokenKey" |
| 55 | +#define kUmeng_MessageAliasTypeCoding @"GLOBAL_KEY" |
| 56 | + |
| 57 | +//信鸽推送 |
| 58 | +#define kXGPush_Id 123456 |
| 59 | +#define kXGPush_Key @"" |
| 60 | + |
| 61 | +//百度定位 |
| 62 | +#define kBaiduGeotableId @"" |
| 63 | +#define kBaiduAK @"" |
| 64 | +#define kBaiduSK @"" |
| 65 | + |
| 66 | +//appStore地址 |
| 67 | +#define kAppUrl @"http://itunes.apple.com/app/id923676989" |
| 68 | +#define kAppReviewURL @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=923676989" |
| 69 | + |
| 70 | +//版本号 |
| 71 | +#define kVersion_Coding [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] |
| 72 | +#define kVersionBuild_Coding [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] |
| 73 | + |
| 74 | +//常用变量 |
| 75 | +#define DebugLog(s, ...) NSLog(@"%s(%d): %@", __FUNCTION__, __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__]) |
| 76 | +#define kTipAlert(_S_, ...) [[[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:(_S_), ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"知道了" otherButtonTitles:nil] show] |
| 77 | + |
| 78 | +#define kKeyWindow [UIApplication sharedApplication].keyWindow |
| 79 | + |
| 80 | +#define kHigher_iOS_6_1 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) |
| 81 | +#define kHigher_iOS_6_1_DIS(_X_) ([[NSNumber numberWithBool:kHigher_iOS_6_1] intValue] * _X_) |
| 82 | +#define kNotHigher_iOS_6_1_DIS(_X_) (-([[NSNumber numberWithBool:kHigher_iOS_6_1] intValue]-1) * _X_) |
| 83 | + |
| 84 | +#define kDevice_Is_iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO) |
| 85 | +#define kDevice_Is_iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO) |
| 86 | + |
| 87 | +#define kScreen_Bounds [UIScreen mainScreen].bounds |
| 88 | +#define kScreen_Height [UIScreen mainScreen].bounds.size.height |
| 89 | +#define kScreen_Width [UIScreen mainScreen].bounds.size.width |
| 90 | +#define kPaddingLeftWidth 15.0 |
| 91 | +#define kMySegmentControl_Height 44.0 |
| 92 | +#define kMySegmentControlIcon_Height 70.0 |
| 93 | + |
| 94 | +#define kBackButtonFontSize 16 |
| 95 | +#define kNavTitleFontSize 19 |
| 96 | +#define kBadgeTipStr @"badgeTip" |
| 97 | + |
| 98 | +#define kDefaultLastId [NSNumber numberWithInteger:99999999] |
| 99 | + |
| 100 | +#define kColor999 [UIColor colorWithHexString:@"0x999999"] |
| 101 | +#define kColorTableBG [UIColor colorWithHexString:@"0xfafafa"] |
| 102 | +#define kColorTableSectionBg [UIColor colorWithHexString:@"0xe5e5e5"] |
| 103 | + |
| 104 | +#define kImage999 [UIImage imageWithColor:kColor999] |
| 105 | + |
| 106 | +#define kPlaceholderMonkeyRoundWidth(_width_) [UIImage imageNamed:[NSString stringWithFormat:@"placeholder_monkey_round_%.0f", _width_]] |
| 107 | +#define kPlaceholderMonkeyRoundView(_view_) [UIImage imageNamed:[NSString stringWithFormat:@"placeholder_monkey_round_%.0f", CGRectGetWidth(_view_.frame)]] |
| 108 | + |
| 109 | +#define kPlaceholderCodingSquareWidth(_width_) [UIImage imageNamed:[NSString stringWithFormat:@"placeholder_coding_square_%.0f", _width_]] |
| 110 | +#define kPlaceholderCodingSquareView(_view_) [UIImage imageNamed:[NSString stringWithFormat:@"placeholder_coding_square_%.0f", CGRectGetWidth(_view_.frame)]] |
| 111 | + |
| 112 | +#define kScaleFrom_iPhone5_Desgin(_X_) (_X_ * (kScreen_Width/320)) |
| 113 | + |
| 114 | +#define kUnReadKey_messages @"messages" |
| 115 | +#define kUnReadKey_notifications @"notifications" |
| 116 | +#define kUnReadKey_project_update_count @"project_update_count" |
| 117 | +#define kUnReadKey_notification_AT @"notification_at" |
| 118 | +#define kUnReadKey_notification_Comment @"notification_comment" |
| 119 | +#define kUnReadKey_notification_System @"notification_system" |
| 120 | + |
| 121 | +//链接颜色 |
| 122 | +#define kLinkAttributes @{(__bridge NSString *)kCTUnderlineStyleAttributeName : [NSNumber numberWithBool:NO],(NSString *)kCTForegroundColorAttributeName : (__bridge id)[UIColor colorWithHexString:@"0x3bbd79"].CGColor} |
| 123 | +#define kLinkAttributesActive @{(NSString *)kCTUnderlineStyleAttributeName : [NSNumber numberWithBool:NO],(NSString *)kCTForegroundColorAttributeName : (__bridge id)[[UIColor colorWithHexString:@"0x1b9d59"] CGColor]} |
| 124 | + |
| 125 | + |
| 126 | +#define kTaskPrioritiesDisplay @[@"有空再看", @"正常处理", @"优先处理", @"十万火急"] |
| 127 | + |
| 128 | + |
| 129 | +///============================================= |
| 130 | +/// @name Weak Object |
| 131 | +///============================================= |
| 132 | +#pragma mark - Weak Object |
| 133 | + |
| 134 | +/** |
| 135 | + * @code |
| 136 | + * ESWeak(imageView, weakImageView); |
| 137 | + * [self testBlock:^(UIImage *image) { |
| 138 | + * ESStrong(weakImageView, strongImageView); |
| 139 | + * strongImageView.image = image; |
| 140 | + * }]; |
| 141 | + * |
| 142 | + * // `ESWeak_(imageView)` will create a var named `weak_imageView` |
| 143 | + * ESWeak_(imageView); |
| 144 | + * [self testBlock:^(UIImage *image) { |
| 145 | + * ESStrong_(imageView); |
| 146 | + * _imageView.image = image; |
| 147 | + * }]; |
| 148 | + * |
| 149 | + * // weak `self` and strong `self` |
| 150 | + * ESWeakSelf; |
| 151 | + * [self testBlock:^(UIImage *image) { |
| 152 | + * ESStrongSelf; |
| 153 | + * _self.image = image; |
| 154 | + * }]; |
| 155 | + * @endcode |
| 156 | + */ |
| 157 | + |
| 158 | +#define ESWeak(var, weakVar) __weak __typeof(&*var) weakVar = var |
| 159 | +#define ESStrong_DoNotCheckNil(weakVar, _var) __typeof(&*weakVar) _var = weakVar |
| 160 | +#define ESStrong(weakVar, _var) ESStrong_DoNotCheckNil(weakVar, _var); if (!_var) return; |
| 161 | + |
| 162 | +#define ESWeak_(var) ESWeak(var, weak_##var); |
| 163 | +#define ESStrong_(var) ESStrong(weak_##var, _##var); |
| 164 | + |
| 165 | +/** defines a weak `self` named `__weakSelf` */ |
| 166 | +#define ESWeakSelf ESWeak(self, __weakSelf); |
| 167 | +/** defines a strong `self` named `_self` from `__weakSelf` */ |
| 168 | +#define ESStrongSelf ESStrong(__weakSelf, _self); |
0 commit comments