├── Project_Structure.png ├── Project_Template ├── Project_Template.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── samsol.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── samsol.xcuserdatad │ │ └── xcschemes │ │ ├── Project_Template.xcscheme │ │ └── xcschememanagement.plist ├── Project_Template │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ └── LaunchScreen.xib │ ├── Controller │ │ ├── MainViewController.h │ │ └── MainViewController.m │ ├── Controls │ │ ├── BaseNavigationController.h │ │ ├── BaseNavigationController.m │ │ ├── BaseView.h │ │ ├── BaseView.m │ │ ├── BaseViewController.h │ │ ├── BaseViewController.m │ │ ├── LoadingView.h │ │ └── LoadingView.m │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── Project_Template.pch │ ├── Utility │ │ ├── AppUtility.h │ │ ├── AppUtility.m │ │ ├── BaseLayout.h │ │ ├── BaseLayout.m │ │ ├── Constants.h │ │ ├── Constants.m │ │ ├── InterfaceUtility.h │ │ ├── InterfaceUtility.m │ │ ├── Reachability.h │ │ └── Reachability.m │ ├── Vendor │ │ ├── AFNetworking │ │ │ ├── AFHTTPRequestOperation.h │ │ │ ├── AFHTTPRequestOperation.m │ │ │ ├── AFHTTPRequestOperationManager.h │ │ │ ├── AFHTTPRequestOperationManager.m │ │ │ ├── AFHTTPSessionManager.h │ │ │ ├── AFHTTPSessionManager.m │ │ │ ├── AFNetworkReachabilityManager.h │ │ │ ├── AFNetworkReachabilityManager.m │ │ │ ├── AFNetworking.h │ │ │ ├── AFSecurityPolicy.h │ │ │ ├── AFSecurityPolicy.m │ │ │ ├── AFURLConnectionOperation.h │ │ │ ├── AFURLConnectionOperation.m │ │ │ ├── AFURLRequestSerialization.h │ │ │ ├── AFURLRequestSerialization.m │ │ │ ├── AFURLResponseSerialization.h │ │ │ ├── AFURLResponseSerialization.m │ │ │ ├── AFURLSessionManager.h │ │ │ └── AFURLSessionManager.m │ │ ├── HTMLString │ │ │ ├── GTMNSString+HTML.h │ │ │ ├── GTMNSString+HTML.m │ │ │ ├── NSString+HTML.h │ │ │ └── NSString+HTML.m │ │ ├── ImageProcessing │ │ │ ├── UIImage+Scale.h │ │ │ └── UIImage+Scale.m │ │ ├── KLCPopup │ │ │ ├── KLCPopup.h │ │ │ └── KLCPopup.m │ │ ├── MFSideMenu │ │ │ ├── MFSideMenu.h │ │ │ ├── MFSideMenuContainerViewController.h │ │ │ ├── MFSideMenuContainerViewController.m │ │ │ ├── MFSideMenuShadow.h │ │ │ ├── MFSideMenuShadow.m │ │ │ ├── UIViewController+MFSideMenuAdditions.h │ │ │ └── UIViewController+MFSideMenuAdditions.m │ │ ├── SDWebImage │ │ │ ├── MKAnnotationView+WebCache.h │ │ │ ├── MKAnnotationView+WebCache.m │ │ │ ├── NSData+ImageContentType.h │ │ │ ├── NSData+ImageContentType.m │ │ │ ├── SDImageCache.h │ │ │ ├── SDImageCache.m │ │ │ ├── SDWebImageCompat.h │ │ │ ├── SDWebImageCompat.m │ │ │ ├── SDWebImageDecoder.h │ │ │ ├── SDWebImageDecoder.m │ │ │ ├── SDWebImageDownloader.h │ │ │ ├── SDWebImageDownloader.m │ │ │ ├── SDWebImageDownloaderOperation.h │ │ │ ├── SDWebImageDownloaderOperation.m │ │ │ ├── SDWebImageManager.h │ │ │ ├── SDWebImageManager.m │ │ │ ├── SDWebImageOperation.h │ │ │ ├── SDWebImagePrefetcher.h │ │ │ ├── SDWebImagePrefetcher.m │ │ │ ├── UIButton+WebCache.h │ │ │ ├── UIButton+WebCache.m │ │ │ ├── UIImage+GIF.h │ │ │ ├── UIImage+GIF.m │ │ │ ├── UIImage+MultiFormat.h │ │ │ ├── UIImage+MultiFormat.m │ │ │ ├── UIImage+WebP.h │ │ │ ├── UIImage+WebP.m │ │ │ ├── UIImageView+HighlightedWebCache.h │ │ │ ├── UIImageView+HighlightedWebCache.m │ │ │ ├── UIImageView+WebCache.h │ │ │ ├── UIImageView+WebCache.m │ │ │ ├── UIView+WebCacheOperation.h │ │ │ └── UIView+WebCacheOperation.m │ │ ├── UIAlertView-Blocks │ │ │ ├── .gitignore │ │ │ ├── UIAlertView+Blocks.h │ │ │ └── UIAlertView+Blocks.m │ │ ├── UIImageViewAligned │ │ │ ├── UIImageViewAligned.h │ │ │ └── UIImageViewAligned.m │ │ ├── UIKit+AFNetworking │ │ │ ├── AFNetworkActivityIndicatorManager.h │ │ │ ├── AFNetworkActivityIndicatorManager.m │ │ │ ├── UIActivityIndicatorView+AFNetworking.h │ │ │ ├── UIActivityIndicatorView+AFNetworking.m │ │ │ ├── UIAlertView+AFNetworking.h │ │ │ ├── UIAlertView+AFNetworking.m │ │ │ ├── UIButton+AFNetworking.h │ │ │ ├── UIButton+AFNetworking.m │ │ │ ├── UIImageView+AFNetworking.h │ │ │ ├── UIImageView+AFNetworking.m │ │ │ ├── UIKit+AFNetworking.h │ │ │ ├── UIProgressView+AFNetworking.h │ │ │ ├── UIProgressView+AFNetworking.m │ │ │ ├── UIRefreshControl+AFNetworking.h │ │ │ ├── UIRefreshControl+AFNetworking.m │ │ │ ├── UIWebView+AFNetworking.h │ │ │ └── UIWebView+AFNetworking.m │ │ └── XMLDocument │ │ │ ├── SMXMLDocument.h │ │ │ └── SMXMLDocument.m │ ├── View │ │ ├── MainView.h │ │ └── MainView.m │ └── main.m └── Project_TemplateTests │ ├── Info.plist │ └── Project_TemplateTests.m └── README.md /Project_Structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samsol38/iOS_Project_Template/e3d14b3eb2588a41382932b189304cf9f5540041/Project_Structure.png -------------------------------------------------------------------------------- /Project_Template/Project_Template.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Project_Template/Project_Template.xcodeproj/project.xcworkspace/xcuserdata/samsol.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samsol38/iOS_Project_Template/e3d14b3eb2588a41382932b189304cf9f5540041/Project_Template/Project_Template.xcodeproj/project.xcworkspace/xcuserdata/samsol.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Project_Template/Project_Template.xcodeproj/xcuserdata/samsol.xcuserdatad/xcschemes/Project_Template.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 38 | 39 | 44 | 45 | 47 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 65 | 66 | 75 | 77 | 83 | 84 | 85 | 86 | 87 | 88 | 94 | 96 | 102 | 103 | 104 | 105 | 107 | 108 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /Project_Template/Project_Template.xcodeproj/xcuserdata/samsol.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Project_Template.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | DD22B9D81B94918C00BE7E17 16 | 17 | primary 18 | 19 | 20 | DD22B9F11B94918C00BE7E17 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "MainViewController.h" 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (strong, nonatomic) UIWindow *window; 15 | 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate (){ 12 | 13 | } 14 | 15 | -(void)registerAPI; 16 | -(void)loadUIControls; 17 | 18 | @end 19 | 20 | @implementation AppDelegate 21 | 22 | #pragma mark - Lifecycle 23 | 24 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 25 | // Override point for customization after application launch. 26 | 27 | [self registerAPI]; 28 | [self loadUIControls]; 29 | 30 | return YES; 31 | } 32 | 33 | - (void)applicationWillResignActive:(UIApplication *)application { 34 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 35 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 36 | } 37 | 38 | - (void)applicationDidEnterBackground:(UIApplication *)application { 39 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 40 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 41 | } 42 | 43 | - (void)applicationWillEnterForeground:(UIApplication *)application { 44 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 45 | } 46 | 47 | - (void)applicationDidBecomeActive:(UIApplication *)application { 48 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 49 | } 50 | 51 | - (void)applicationWillTerminate:(UIApplication *)application { 52 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 53 | } 54 | 55 | 56 | #pragma mark - Public Interface 57 | 58 | #pragma mark - Internal Helpers 59 | 60 | -(void)registerAPI{ 61 | 62 | } 63 | 64 | -(void)loadUIControls{ 65 | 66 | MainViewController *mainViewController = [[MainViewController alloc] init]; 67 | BaseNavigationController *navigationController = [[BaseNavigationController alloc] initWithRootViewController:mainViewController]; 68 | 69 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 70 | [self.window setRootViewController:navigationController]; 71 | [self.window makeKeyAndVisible]; 72 | 73 | mainViewController = nil; 74 | navigationController = nil; 75 | 76 | } 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Controller/MainViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.h 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import "BaseViewController.h" 10 | #import "MainView.h" 11 | 12 | @interface MainViewController : BaseViewController 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Controller/MainViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainViewController.m 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import "MainViewController.h" 10 | 11 | @interface MainViewController(){ 12 | MainView *mainView; 13 | } 14 | 15 | @end 16 | 17 | @implementation MainViewController 18 | 19 | #pragma mark - Lifecycle 20 | 21 | - (id)init{ 22 | 23 | MainView *subView = [[MainView alloc] init]; 24 | self = [super initWithView:subView andNavigationTitle:@"MainView"]; 25 | 26 | if(self){ 27 | mainView = subView; 28 | [self loadViewControls]; 29 | [self setViewControlsLayout]; 30 | subView = nil; 31 | } 32 | 33 | return self; 34 | } 35 | 36 | - (void)dealloc{ 37 | mainView = nil; 38 | } 39 | 40 | - (void)viewDidLoad { 41 | [super viewDidLoad]; 42 | // Do any additional setup after loading the view. 43 | } 44 | 45 | - (void)viewDidAppear:(BOOL)animated{ 46 | [super viewDidAppear:animated]; 47 | 48 | } 49 | 50 | - (void)viewWillAppear:(BOOL)animated{ 51 | [super viewWillAppear:animated]; 52 | 53 | } 54 | 55 | - (void)viewWillDisappear:(BOOL)animated{ 56 | [super viewWillDisappear:animated]; 57 | 58 | } 59 | 60 | - (void)didReceiveMemoryWarning { 61 | [super didReceiveMemoryWarning]; 62 | // Dispose of any resources that can be recreated. 63 | } 64 | 65 | #pragma mark - Layout 66 | 67 | -(void)loadViewControls{ 68 | [super loadViewControls]; 69 | 70 | } 71 | 72 | -(void)setViewControlsLayout{ 73 | [super setViewControlsLayout]; 74 | [super expandViewInsideView]; 75 | } 76 | 77 | #pragma mark - Public Interface 78 | 79 | 80 | #pragma mark - User Interaction 81 | 82 | 83 | #pragma mark - Internal Helpers 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Controls/BaseNavigationController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseNavigationController.h 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface BaseNavigationController : UINavigationController 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Controls/BaseNavigationController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseNavigationController.m 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import "BaseNavigationController.h" 10 | 11 | @interface BaseNavigationController(){ 12 | 13 | } 14 | 15 | -(void)setDefaultParameters; 16 | 17 | @end 18 | 19 | @implementation BaseNavigationController 20 | 21 | #pragma mark - Lifecycle 22 | 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | // Do any additional setup after loading the view. 26 | 27 | [self setDefaultParameters]; 28 | 29 | } 30 | 31 | - (void)didReceiveMemoryWarning { 32 | [super didReceiveMemoryWarning]; 33 | // Dispose of any resources that can be recreated. 34 | } 35 | 36 | #pragma mark - Public Interface 37 | 38 | 39 | #pragma mark - User Interaction 40 | 41 | 42 | #pragma mark - Internal Helpers 43 | 44 | -(void)setDefaultParameters{ 45 | self.edgesForExtendedLayout = UIRectEdgeNone; 46 | [self.navigationBar setTranslucent:NO]; 47 | 48 | if ([self respondsToSelector:@selector(interactivePopGestureRecognizer)]) { 49 | self.navigationController.interactivePopGestureRecognizer.enabled = NO; 50 | } 51 | 52 | UIFont *navigationBarFont = UIFontFromString(@"AppleSDGothicNeo-Medium;17"); 53 | 54 | NSDictionary *navigationAttributeDictionary = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects: navigationBarFont, nil] 55 | forKeys:[NSArray arrayWithObjects: NSFontAttributeName, nil]]; 56 | [[UINavigationBar appearance] setTitleTextAttributes:navigationAttributeDictionary]; 57 | 58 | /* 59 | 60 | UIColor *backgroundColor = [UIColor whiteColor]; 61 | NSDictionary *navigationAttributeDictionary = [NSDictionary dictionaryWithObjects:@[backgroundColor] 62 | forKeys:@[NSBackgroundColorAttributeName]]; 63 | [[UINavigationBar appearanceWhenContainedIn:[MFMailComposeViewController class], nil] setTitleTextAttributes:textAttributeDictionary]; 64 | 65 | */ 66 | 67 | [self.navigationBar setTintColor:UIColorFromRGB(0x000000)]; 68 | [self.navigationBar setTranslucent:NO]; 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Controls/BaseView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseView.h 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "LoadingView.h" 11 | 12 | @class BaseLayout; 13 | 14 | @interface BaseView : UIView{ 15 | 16 | BaseLayout *layout; 17 | 18 | UILabel *errorMessageLabel; 19 | LoadingView *loadingView; 20 | 21 | NSOperationQueue *queue; 22 | } 23 | 24 | -(id)init; 25 | -(void)loadViewControls; 26 | -(void)setViewControlsLayout; 27 | 28 | -(void)loadOperationServerRequest; 29 | -(void)beginServerRequest; 30 | 31 | -(void)displayErrorMessageLabel:(NSString*)errorMessage; 32 | +(NSMutableDictionary*)getRequestDictionaryFromView:(UIView*)iView; 33 | 34 | +(BOOL)isFirstTextControlInSuperview:(UIView*)superview textControl:(UIView*)textControl; 35 | +(BOOL)isLastTextControlInSuperview:(UIView*)superview textControl:(UIView*)textControl; 36 | 37 | +(BOOL)isTextControl:(UIView*)view; 38 | +(BOOL)isTextFieldControl:(UIView*)view; 39 | +(BOOL)isTextViewControl:(UIView*)view; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Controls/BaseView.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseView.m 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import "BaseView.h" 10 | #import "BaseLayout.h" 11 | 12 | @interface BaseView(){ 13 | 14 | } 15 | 16 | @end 17 | 18 | @implementation BaseView 19 | 20 | static NSString *KControlResponseKey = @"ControlResponseKey"; 21 | 22 | #pragma mark - Lifecycle 23 | 24 | -(id)init{ 25 | 26 | self = [super init]; 27 | if(self){ 28 | 29 | } 30 | return self; 31 | } 32 | 33 | -(void)dealloc{ 34 | 35 | layout = nil; 36 | 37 | errorMessageLabel = nil; 38 | loadingView = nil; 39 | 40 | if(queue != nil){ 41 | [queue cancelAllOperations]; 42 | } 43 | queue = nil; 44 | } 45 | 46 | #pragma mark - Layout 47 | 48 | -(void)loadViewControls{ 49 | 50 | [self setBackgroundColor:[UIColor whiteColor]]; 51 | [self setTranslatesAutoresizingMaskIntoConstraints:NO]; 52 | 53 | /* errorMessageLabel Allocation */ 54 | 55 | errorMessageLabel = [[UILabel alloc] init]; 56 | [errorMessageLabel setTranslatesAutoresizingMaskIntoConstraints:NO]; 57 | [errorMessageLabel setFont:UIFontFromString(@"AppleSDGothicNeo-Medium;15")]; 58 | [errorMessageLabel setNumberOfLines:0]; 59 | [errorMessageLabel setPreferredMaxLayoutWidth:200]; 60 | [errorMessageLabel setTextAlignment:NSTextAlignmentCenter]; 61 | [self addSubview:errorMessageLabel]; 62 | [self displayErrorMessageLabel:nil]; 63 | 64 | } 65 | 66 | -(void)setViewControlsLayout{ 67 | 68 | #if KShowLayOutArea 69 | [self setBackgroundColor:[UIColor greenColor]]; 70 | #endif 71 | 72 | layout = [[BaseLayout alloc] init]; 73 | 74 | layout.viewDictionary = NSDictionaryOfVariableBindings(errorMessageLabel); 75 | 76 | /* errorLabel Layout */ 77 | 78 | layout.control_H = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[errorMessageLabel]|" options:0 metrics:nil views:layout.viewDictionary]; 79 | [self addConstraints:layout.control_H]; 80 | 81 | layout.position_Top = [NSLayoutConstraint constraintWithItem:errorMessageLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0f constant:0.0f]; 82 | 83 | layout.position_Bottom = [NSLayoutConstraint constraintWithItem:errorMessageLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTop multiplier:1.0f constant:0.0f]; 84 | 85 | [self addConstraints:@[layout.position_Top, layout.position_Bottom]]; 86 | 87 | layout.control_H = nil; 88 | layout.position_Top = nil; 89 | layout.position_Bottom = nil; 90 | 91 | layout.viewDictionary = nil; 92 | } 93 | 94 | #pragma mark - Public Interface 95 | 96 | -(void)displayErrorMessageLabel:(NSString*)errorMessage{ 97 | 98 | [errorMessageLabel setHidden:YES]; 99 | [errorMessageLabel setText:@""]; 100 | [self sendSubviewToBack:errorMessageLabel]; 101 | 102 | if(errorMessage != nil){ 103 | [self bringSubviewToFront:errorMessageLabel]; 104 | [errorMessageLabel setHidden:NO]; 105 | [errorMessageLabel setText:errorMessage]; 106 | } 107 | 108 | [errorMessageLabel layoutSubviews]; 109 | } 110 | 111 | +(NSMutableDictionary*)getRequestDictionaryFromView:(UIView*)iView{ 112 | 113 | id textControl = nil; 114 | NSString *textFromTextControl = nil; 115 | NSString *requestKey = nil; 116 | 117 | NSMutableDictionary *requestDictionary = [NSMutableDictionary dictionary]; 118 | 119 | for(UIView *view in [iView subviews]){ 120 | 121 | if([BaseView isTextControl:view]){ 122 | 123 | if([BaseView isTextFieldControl:view]){ 124 | 125 | textControl = (UITextField*)view; 126 | textFromTextControl = [textControl text]; 127 | 128 | }else if([BaseView isTextViewControl:view]){ 129 | 130 | textControl = (UITextView*)view; 131 | textFromTextControl = [textControl text]; 132 | 133 | } 134 | 135 | requestKey = [view.layer valueForKey:KControlResponseKey]; 136 | if(requestKey != nil && textFromTextControl != nil){ 137 | [requestDictionary setObject:textFromTextControl forKey:requestKey]; 138 | } 139 | } 140 | } 141 | 142 | textControl = nil; 143 | textFromTextControl = nil; 144 | requestKey = nil; 145 | 146 | return requestDictionary; 147 | } 148 | 149 | +(BOOL)isFirstTextControlInSuperview:(UIView*)superview textControl:(UIView*)textControl{ 150 | 151 | BOOL isFirstTextControl = true; 152 | 153 | NSInteger textControlIndex = -1; 154 | NSInteger viewControlIndex = -1; 155 | 156 | 157 | if([superview.subviews containsObject:textControl]){ 158 | textControlIndex = [superview.subviews indexOfObject:textControl]; 159 | } 160 | 161 | for(UIView *view in superview.subviews){ 162 | 163 | if([BaseView isTextControl:view] && ![textControl isEqual:view]){ 164 | viewControlIndex = [superview.subviews indexOfObject:view]; 165 | 166 | if(viewControlIndex < textControlIndex){ 167 | isFirstTextControl = false; 168 | break; 169 | } 170 | } 171 | } 172 | return isFirstTextControl; 173 | } 174 | 175 | +(BOOL)isLastTextControlInSuperview:(UIView*)superview textControl:(UIView*)textControl{ 176 | 177 | BOOL isLastTextControl = true; 178 | 179 | NSInteger textControlIndex = -1; 180 | NSInteger viewControlIndex = -1; 181 | 182 | 183 | if([superview.subviews containsObject:textControl]){ 184 | textControlIndex = [superview.subviews indexOfObject:textControl]; 185 | } 186 | 187 | for(UIView *view in superview.subviews){ 188 | 189 | if([BaseView isTextControl:view] && ![textControl isEqual:view]){ 190 | viewControlIndex = [superview.subviews indexOfObject:view]; 191 | 192 | if(viewControlIndex > textControlIndex){ 193 | isLastTextControl = false; 194 | break; 195 | } 196 | } 197 | } 198 | 199 | return isLastTextControl; 200 | } 201 | 202 | 203 | +(BOOL)isTextControl:(UIView*)view{ 204 | return ([BaseView isTextFieldControl:view] || [BaseView isTextViewControl:view]); 205 | } 206 | 207 | +(BOOL)isTextFieldControl:(UIView*)view{ 208 | return ([view isKindOfClass:[UITextField class]]); 209 | } 210 | 211 | +(BOOL)isTextViewControl:(UIView*)view{ 212 | return ([view isKindOfClass:[UITextView class]]); 213 | } 214 | 215 | 216 | #pragma mark - Internal Helpers 217 | 218 | -(void)loadOperationServerRequest{ 219 | 220 | if(queue == nil){ 221 | queue = [[NSOperationQueue alloc] init]; 222 | } 223 | [queue cancelAllOperations]; 224 | [self displayErrorMessageLabel:nil]; 225 | } 226 | 227 | -(void)beginServerRequest{ 228 | } 229 | 230 | 231 | @end -------------------------------------------------------------------------------- /Project_Template/Project_Template/Controls/BaseViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.h 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class BaseView; 12 | @class BaseLayout; 13 | 14 | @interface BaseViewController : UIViewController 15 | 16 | @property(strong, nonatomic)BaseView *aView; 17 | @property(strong, nonatomic)BaseLayout *layout; 18 | 19 | -(id)initWithView:(UIView*)iView; 20 | - (id)initWithView:(UIView *)iView andNavigationTitle:(NSString*)titleString; 21 | 22 | -(void)loadViewControls; 23 | -(void)setViewControlsLayout; 24 | -(void)expandViewInsideView; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Controls/BaseViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseViewController.m 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import "BaseViewController.h" 10 | #import "BaseLayout.h" 11 | 12 | @interface BaseViewController(){ 13 | NSString *navigationTitleString; 14 | } 15 | 16 | @end 17 | 18 | @implementation BaseViewController 19 | 20 | #pragma mark - Lifecycle 21 | 22 | - (id)initWithView:(UIView *)iView{ 23 | self = [self initWithView:iView andNavigationTitle:@""]; 24 | 25 | if(self){ 26 | 27 | } 28 | 29 | return self; 30 | } 31 | 32 | - (id)initWithView:(BaseView *)iView andNavigationTitle:(NSString*)titleString{ 33 | self = [super init]; 34 | 35 | if(self){ 36 | self.aView = iView; 37 | navigationTitleString = titleString; 38 | [self showStatusBar]; 39 | } 40 | 41 | return self; 42 | } 43 | 44 | - (void)viewDidAppear:(BOOL)animated{ 45 | [super viewDidAppear:animated]; 46 | 47 | [self.navigationItem setTitle:navigationTitleString]; 48 | } 49 | 50 | - (void)viewWillAppear:(BOOL)animated{ 51 | [super viewWillAppear:animated]; 52 | 53 | [self.navigationItem setTitle:navigationTitleString]; 54 | [self.navigationController setNavigationBarHidden:NO animated:YES]; 55 | } 56 | 57 | - (void)viewWillDisappear:(BOOL)animated{ 58 | [super viewWillDisappear:animated]; 59 | 60 | [self.navigationItem setTitle:@""]; 61 | } 62 | 63 | - (void)dealloc{ 64 | self.aView = nil; 65 | navigationTitleString = nil; 66 | 67 | self.layout = nil; 68 | } 69 | 70 | #pragma mark - Layout 71 | 72 | -(void)loadViewControls{ 73 | [self.view addSubview:self.aView]; 74 | } 75 | 76 | -(void)setViewControlsLayout{ 77 | 78 | #if KHideLayOutArea 79 | [self.view setBackgroundColor:[UIColor yellowColor]]; 80 | #endif 81 | 82 | /* Layout Allocation */ 83 | 84 | self.layout = [[BaseLayout alloc] initWithView:self.view]; 85 | } 86 | 87 | -(void)expandViewInsideView{ 88 | [self.layout expandView:self.aView insideView:self.view]; 89 | } 90 | 91 | 92 | #pragma mark - Public Interface 93 | 94 | 95 | #pragma mark - User Interaction 96 | 97 | 98 | #pragma mark - Internal Helpers 99 | 100 | -(void)showStatusBar{ 101 | if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) { 102 | CGRect screen = [[UIScreen mainScreen] bounds]; 103 | if (self.navigationController) { 104 | CGRect frame = self.navigationController.view.frame; 105 | frame.origin.y = 20; 106 | frame.size.height = screen.size.height - 20; 107 | self.navigationController.view.frame = frame; 108 | } else { 109 | if ([self respondsToSelector: @selector(containerView)]) { 110 | UIView *containerView = (UIView *)[self performSelector: @selector(containerView)]; 111 | 112 | CGRect frame = containerView.frame; 113 | frame.origin.y = 20; 114 | frame.size.height = screen.size.height - 20; 115 | containerView.frame = frame; 116 | } else { 117 | CGRect frame = self.view.frame; 118 | frame.origin.y = 20; 119 | frame.size.height = screen.size.height - 20; 120 | self.view.frame = frame; 121 | } 122 | } 123 | } 124 | } 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Controls/LoadingView.h: -------------------------------------------------------------------------------- 1 | // 2 | // LoadingView.h 3 | // Project_Template 4 | // 5 | // Created by WebMobTech-iMac on 14/04/15. 6 | // Copyright (c) 2015 Webmob. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import "Constants.h" 12 | #import "InterfaceUtility.h" 13 | 14 | #define KContainerViewWidth (IS_IPAD ? 120.0f : 80.0f) 15 | #define KContainerViewHeight (IS_IPAD ? 220.0f : 180.0f) 16 | 17 | #define kDialogBackgroundColor [UIColor colorWithRed:113.0f/255.0f green:84.0f/255.0f blue:74.0f/255.0f alpha:1.0f] 18 | #define kDialogFont [UIFont fontWithName:@"AppleSDGothicNeo-Bold" size:14.0f] 19 | 20 | @interface LoadingView : UIView 21 | 22 | -(id)initWithSuperView:(UIView*)iSuperView; 23 | 24 | -(void)showLoadingViewWithCompletion:(void (^)(BOOL finished))completion; 25 | -(void)showLoadingViewWithText:(NSString*)labelText andCompletion:(void (^)(BOOL finished))completion; 26 | -(void)hideLoadingViewWithCompletion:(void (^)(BOOL finished))completion; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /Project_Template/Project_Template/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.samsol.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | NSMainNibFile 26 | LaunchScreen 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Project_Template.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Project_Template.pch 3 | // Project_Template 4 | // 5 | // Created by SamSol on 31/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #ifndef Project_Template_Project_Template_pch 10 | #define Project_Template_Project_Template_pch 11 | 12 | #import 13 | #import 14 | 15 | /* Vender API */ 16 | 17 | #import "AFNetworking.h" 18 | #import "UIImageView+WebCache.h" 19 | #import "UIImage+Scale.h" 20 | #import "UIAlertView+Blocks.h" 21 | #import "KLCPopup.h" 22 | #import "MFSideMenu.h" 23 | #import "NSString+HTML.h" 24 | #import "SMXMLDocument.h" 25 | 26 | /* Custom Controls */ 27 | 28 | #import "AppDelegate.h" 29 | #import "BaseView.h" 30 | #import "BaseViewController.h" 31 | #import "BaseNavigationController.h" 32 | #import "LoadingView.h" 33 | 34 | /* Utility API */ 35 | 36 | #import "Constants.h" 37 | #import "AppUtility.h" 38 | #import "InterfaceUtility.h" 39 | #import "BaseLayout.h" 40 | #import "Reachability.h" 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Utility/AppUtility.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppUtility.h 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppUtility : NSObject 12 | 13 | /* Network Connection Check */ 14 | 15 | +(void)isNetworkAvailableWithBlock:(void (^)(BOOL wasSuccessful))completion; 16 | +(NSString*)getURLStringFromDictionary:(NSDictionary*)dictionary; 17 | 18 | /* User Defaults Methods */ 19 | 20 | +(NSString*)getUserDefaultsObjectForKey:(NSString*)key; 21 | +(void)setUserDefaultsObject:(NSString*)value forKey:(NSString*)key; 22 | +(void)clearUserDefaultsForKey:(NSString*)key; 23 | +(void)clearUserDefaults; 24 | 25 | /* Get Device Identifier */ 26 | 27 | +(NSString *)getDeviceIdentifier; 28 | 29 | /* Object Misc Methods */ 30 | 31 | +(AppDelegate*)getAppDelegate; 32 | 33 | /* Date-Time Methods */ 34 | 35 | +(NSString*)getCurrentDateInFormat:(NSString*)format; 36 | +(NSString *)convertStringDateFromFormat:(NSString*)inputFormat toFormat:(NSString*)outputFormat fromString:(NSString*)dateString; 37 | +(NSString*)getTimeStampForCurrentTime; 38 | 39 | +(BOOL)isValidEmail:(NSString *)checkString; 40 | 41 | 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Utility/AppUtility.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppUtility.m 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import "AppUtility.h" 10 | 11 | static dispatch_queue_t networkQueue; 12 | 13 | static Reachability* reach; 14 | 15 | @implementation AppUtility 16 | 17 | #pragma mark - Network Connection Check Methods 18 | 19 | +(void)isNetworkAvailableWithBlock:(void (^)(BOOL wasSuccessful))completion{ 20 | 21 | static dispatch_once_t queueCreationGuard; 22 | 23 | dispatch_once(&queueCreationGuard, ^{ 24 | networkQueue = dispatch_queue_create("NetworkQueue", NULL); 25 | }); 26 | 27 | __block Reachability* blockReach = reach; 28 | 29 | dispatch_async(networkQueue, ^{ 30 | blockReach = [Reachability reachabilityWithHostname:@"www.google.com"]; 31 | blockReach.reachableBlock = ^(Reachability *iReach){ 32 | [iReach stopNotifier]; 33 | completion(true); 34 | }; 35 | 36 | blockReach.unreachableBlock = ^(Reachability *iReach){ 37 | [iReach stopNotifier]; 38 | completion(false); 39 | }; 40 | [blockReach startNotifier]; 41 | }); 42 | } 43 | 44 | +(NSString*)getURLStringFromDictionary:(NSDictionary*)dictionary{ 45 | 46 | NSMutableString *urlStringWithDetails = [NSMutableString stringWithString:@""]; 47 | NSInteger count = [[dictionary allKeys]count]; 48 | 49 | for(NSString *string in [dictionary allKeys]){ 50 | 51 | if([[dictionary allKeys] indexOfObject:string] < count-1){ 52 | [urlStringWithDetails appendFormat:@"%@=%@&", string, dictionary[string]]; 53 | }else{ 54 | [urlStringWithDetails appendFormat:@"%@=%@", string, dictionary[string]]; 55 | } 56 | } 57 | 58 | NSString *finalString = [NSString stringWithString:urlStringWithDetails]; 59 | urlStringWithDetails = nil; 60 | 61 | return finalString; 62 | } 63 | 64 | #pragma mark - User Defaults Methods 65 | 66 | +(NSObject*)getUserDefaultsObjectForKey:(NSString*)key{ 67 | return [[NSUserDefaults standardUserDefaults] objectForKey:key]; 68 | } 69 | 70 | +(void)setUserDefaultsObject:(NSObject*)object forKey:(NSString*)key{ 71 | [[NSUserDefaults standardUserDefaults] setValue:object forKey:key]; 72 | [[NSUserDefaults standardUserDefaults] synchronize]; 73 | } 74 | 75 | +(void)clearUserDefaultsForKey:(NSString*)key{ 76 | [[NSUserDefaults standardUserDefaults] removeObjectForKey:key]; 77 | [[NSUserDefaults standardUserDefaults] synchronize]; 78 | } 79 | 80 | +(void)clearUserDefaults{ 81 | NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier]; 82 | [[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain]; 83 | [[NSUserDefaults standardUserDefaults] synchronize]; 84 | } 85 | 86 | 87 | #pragma mark - UIDevice Methods 88 | 89 | +(NSString *)getDeviceIdentifier{ 90 | 91 | NSString *deviceUUID = [[[UIDevice currentDevice] identifierForVendor] UUIDString]; 92 | NSLog(@"Device ID: %@", deviceUUID); 93 | 94 | return deviceUUID; 95 | } 96 | 97 | #pragma mark - Misc Methods 98 | 99 | +(AppDelegate*)getAppDelegate{ 100 | return (AppDelegate*)[[UIApplication sharedApplication] delegate]; 101 | } 102 | 103 | 104 | #pragma mark - Time-Date Methods 105 | 106 | +(NSString*)getCurrentDateInFormat:(NSString*)format{ 107 | 108 | NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; 109 | 110 | NSDateFormatter *timeFormatter = [[NSDateFormatter alloc] init]; 111 | [timeFormatter setDateFormat: format]; 112 | [timeFormatter setTimeZone:[NSTimeZone localTimeZone]]; 113 | [timeFormatter setLocale:usLocale]; 114 | 115 | NSDate *date = [NSDate date]; 116 | NSString *stringFromDate = [timeFormatter stringFromDate:date]; 117 | 118 | usLocale = nil; 119 | timeFormatter = nil; 120 | 121 | return stringFromDate; 122 | } 123 | 124 | +(NSString *)convertStringDateFromFormat:(NSString*)inputFormat toFormat:(NSString*)outputFormat fromString:(NSString*)dateString{ 125 | 126 | NSDateFormatter *dateFormatter = nil; 127 | 128 | dateFormatter = [[NSDateFormatter alloc] init]; 129 | [dateFormatter setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US"]]; 130 | [dateFormatter setDateFormat:inputFormat]; 131 | NSDate * date = [dateFormatter dateFromString:dateString]; 132 | dateFormatter = nil; 133 | 134 | dateFormatter = [[NSDateFormatter alloc] init]; 135 | [dateFormatter setLocale:[NSLocale localeWithLocaleIdentifier:@"en_US"]]; 136 | [dateFormatter setDateFormat:outputFormat]; 137 | NSString *resultedDateString = [dateFormatter stringFromDate:date]; 138 | dateFormatter = nil; 139 | date = nil; 140 | 141 | return resultedDateString; 142 | } 143 | 144 | +(NSString*)getTimeStampForCurrentTime{ 145 | NSString *timestamp = [[NSNumber numberWithLongLong:[[NSDate date] timeIntervalSince1970] * 1000] stringValue]; 146 | return timestamp; 147 | } 148 | 149 | +(BOOL)isValidEmail:(NSString *)checkString{ 150 | 151 | BOOL stricterFilter = NO; 152 | NSString *stricterFilterString = @"^[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}$"; 153 | NSString *laxString = @"^.+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*$"; 154 | NSString *emailRegex = stricterFilter ? stricterFilterString : laxString; 155 | NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex]; 156 | return [emailTest evaluateWithObject:checkString]; 157 | } 158 | 159 | 160 | @end 161 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Utility/BaseLayout.h: -------------------------------------------------------------------------------- 1 | // 2 | // BaseLayout.h 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface BaseLayout : NSObject 13 | 14 | @property(strong, nonatomic)NSLayoutConstraint *position_Top, *position_Bottom; 15 | @property(strong, nonatomic)NSLayoutConstraint *position_Left, *position_Right; 16 | @property(strong, nonatomic)NSLayoutConstraint *size_Width, *size_Height; 17 | @property(strong, nonatomic)NSLayoutConstraint *position_CenterX, *position_CenterY; 18 | 19 | @property(strong, nonatomic)NSArray *control_H, *control_V; 20 | @property(strong, nonatomic)NSDictionary *viewDictionary, *metrics; 21 | 22 | -(id)initWithView:(UIView*)iView; 23 | -(void)expandViewInsideView:(UIView*)mainView; 24 | -(void)expandView:(UIView*)containerView insideView:(UIView*)mainView; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Utility/BaseLayout.m: -------------------------------------------------------------------------------- 1 | // 2 | // BaseLayout.m 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import "BaseLayout.h" 10 | 11 | @interface BaseLayout(){ 12 | UIView *view; 13 | } 14 | 15 | @end 16 | 17 | @implementation BaseLayout 18 | 19 | #pragma mark - Lifecycle 20 | 21 | -(id)initWithView:(UIView*)iView{ 22 | self = [super init]; 23 | if(self){ 24 | view = iView; 25 | } 26 | return self; 27 | } 28 | 29 | -(void)dealloc{ 30 | view = nil; 31 | 32 | self.position_Top = nil; 33 | self.position_Bottom = nil; 34 | 35 | self.position_Left = nil; 36 | self.position_Right = nil; 37 | 38 | self.size_Width = nil; 39 | self.size_Height = nil; 40 | 41 | self.position_CenterX = nil; 42 | self.position_CenterY = nil; 43 | 44 | self.control_H = nil; 45 | self.control_V = nil; 46 | 47 | self.viewDictionary = nil; 48 | self.metrics = nil; 49 | } 50 | 51 | -(void)expandViewInsideView:(UIView*)mainView{ 52 | 53 | NSDictionary *dictionary = NSDictionaryOfVariableBindings(view); 54 | 55 | self.control_H = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[view]|" options:0 metrics:nil views:dictionary]; 56 | self.control_V = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[view]|" options:0 metrics:nil views:dictionary]; 57 | 58 | [mainView addConstraints:self.control_H]; 59 | [mainView addConstraints:self.control_V]; 60 | 61 | self.control_H = nil; 62 | self.control_V = nil; 63 | 64 | dictionary = nil; 65 | } 66 | 67 | -(void)expandView:(UIView*)containerView insideView:(UIView*)mainView{ 68 | 69 | NSDictionary *dictionary = NSDictionaryOfVariableBindings(containerView); 70 | 71 | self.control_H = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[containerView]|" options:0 metrics:nil views:dictionary]; 72 | self.control_V = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[containerView]|" options:0 metrics:nil views:dictionary]; 73 | 74 | [mainView addConstraints:self.control_H]; 75 | [mainView addConstraints:self.control_V]; 76 | 77 | self.control_H = nil; 78 | self.control_V = nil; 79 | 80 | dictionary = nil; 81 | } 82 | 83 | 84 | @end 85 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Utility/Constants.h: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.h 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface Constants : NSObject 12 | 13 | /* System Oriented Constants */ 14 | 15 | #define KShowLayOutArea 1 16 | #define KHideLayOutArea 0 17 | #define KShowVersionNumber 1 18 | 19 | /*****************************/ 20 | /* Useful Macro Function */ 21 | /*****************************/ 22 | 23 | /* Disable Log Message in Release version but not in Debug version */ 24 | 25 | #ifdef DEBUG 26 | # define NSLog(...) NSLog(__VA_ARGS__) 27 | #else 28 | # define NSLog(...) 29 | #endif 30 | 31 | /* Check that device is iPad or not */ 32 | 33 | #define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 34 | 35 | /* Check that System Version is v version or later */ 36 | 37 | #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 38 | 39 | /* Append two Strings */ 40 | 41 | #define AppendString(string1, string2) [NSString stringWithFormat:@"%@%@", string1, string2] 42 | 43 | /* Convert HTML Color Code to UIColor Ex. :0xCECECE */ 44 | 45 | #define UIColorFromRGB(rgbValue) [UIColor \ 46 | colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ 47 | green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ 48 | blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0] 49 | 50 | /* Convert HTML Color Code with Alpha Value to UIColor Ex. :0xCECECE and Alpha Value Ex.:0.4 */ 51 | 52 | #define UIColorFromRGBWithAlpha(rgbValue, a) [UIColor \ 53 | colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \ 54 | green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \ 55 | blue:((float)(rgbValue & 0xFF))/255.0 alpha:a] 56 | 57 | /* Get UIFont object from Font name and size */ 58 | 59 | #define UIFontFromNameAndSize(_name_, _size_) ((UIFont *)[UIFont fontWithName:(NSString *)(_name_) size:(CGFloat)(_size_)]) 60 | 61 | /* Get UIFont object from Font name and size seperated by ';' Ex. : UIFontFromString(@"Arial;10.0f") */ 62 | 63 | #define UIFontFromString(fontString) ((UIFont *)[UIFont fontWithName:[fontString componentsSeparatedByString:@";"][0] size:[[fontString componentsSeparatedByString:@";"][1] floatValue]]) 64 | 65 | /**************************/ 66 | /* Comman Constants */ 67 | /**************************/ 68 | 69 | 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Utility/Constants.m: -------------------------------------------------------------------------------- 1 | // 2 | // Constants.m 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import "Constants.h" 10 | 11 | @implementation Constants 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Utility/InterfaceUtility.h: -------------------------------------------------------------------------------- 1 | // 2 | // InterfaceUtility.h 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | #import 12 | 13 | typedef void (^TableCellDidSelectEvent)(NSInteger cellIndex, id object); 14 | typedef void (^ControlTouchUpInsideEvent)(id sender, id object); 15 | 16 | @interface InterfaceUtility : NSObject 17 | 18 | extern NSString *const KNoInternetMessage; 19 | 20 | +(void)displayAlertViewWithTitle:(NSString*)title andMessage:(NSString*)message; 21 | +(void)displayAlertViewForNoInternetWithTerminateApp:(BOOL)wantTerminateApp; 22 | 23 | +(CGSize)getDeviceScreenSize; 24 | 25 | +(void)setBorderColor:(UIColor*)borderColor width:(CGFloat)width andRadius:(CGFloat)radius ofView:(UIView*)view; 26 | 27 | +(void)setTopBorderColor:(UIColor*)borderColor width:(CGFloat)width ofView:(UIView*)view; 28 | +(void)setBottomBorderColor:(UIColor*)borderColor width:(CGFloat)width ofView:(UIView*)view; 29 | +(void)setLeftBorderColor:(UIColor*)borderColor width:(CGFloat)width ofView:(UIView*)view; 30 | +(void)setRightBorderColor:(UIColor*)borderColor width:(CGFloat)width ofView:(UIView*)view; 31 | 32 | +(void)setCircleViewWith:(UIColor*)borderColor width:(CGFloat)width ofView:(UIView*)view; 33 | +(void)setIndicatorAtBottomWithInnerFillColor:(UIColor*)innerFillColor ofView:(UIView*)iView; 34 | 35 | +(void)removeIndicatorFromView:(UIView*)iView; 36 | 37 | +(UIViewController *)getViewControllerFromSubView:(UIView*)view; 38 | 39 | +(CGSize)getAppropriateSizeFromSize:(CGSize)iSize withDivision:(CGFloat)divider andInterSpacing:(CGFloat)interSpacing; 40 | 41 | +(CGSize)aspectScaledImageSizeForImageView:(UIImageView *)iv image:(UIImage *)image; 42 | +(UIImage *)cropImage:(UIImage*)image fromRect:(CGRect)rect; 43 | + (UIImage *)imageFromColor:(UIColor *)color; 44 | 45 | +(UIColor *)colorWithHexString:(NSString *)str; 46 | +(UIColor *)colorWithHex:(UInt32)col; 47 | 48 | +(CGFloat)textViewHeightForAttributedText:(NSAttributedString *)text andWidth:(CGFloat)width; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Utility/Reachability.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2011, Tony Million. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | 28 | #import 29 | #import 30 | 31 | 32 | /** 33 | * Create NS_ENUM macro if it does not exist on the targeted version of iOS or OS X. 34 | * 35 | * @see http://nshipster.com/ns_enum-ns_options/ 36 | **/ 37 | #ifndef NS_ENUM 38 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 39 | #endif 40 | 41 | extern NSString *const kReachabilityChangedNotification; 42 | 43 | typedef NS_ENUM(NSInteger, NetworkStatus) { 44 | // Apple NetworkStatus Compatible Names. 45 | NotReachable = 0, 46 | ReachableViaWiFi = 2, 47 | ReachableViaWWAN = 1 48 | }; 49 | 50 | @class Reachability; 51 | 52 | typedef void (^NetworkReachable)(Reachability * reachability); 53 | typedef void (^NetworkUnreachable)(Reachability * reachability); 54 | 55 | 56 | @interface Reachability : NSObject 57 | 58 | @property (nonatomic, copy) NetworkReachable reachableBlock; 59 | @property (nonatomic, copy) NetworkUnreachable unreachableBlock; 60 | 61 | @property (nonatomic, assign) BOOL reachableOnWWAN; 62 | 63 | 64 | +(instancetype)reachabilityWithHostname:(NSString*)hostname; 65 | // This is identical to the function above, but is here to maintain 66 | //compatibility with Apples original code. (see .m) 67 | +(instancetype)reachabilityWithHostName:(NSString*)hostname; 68 | +(instancetype)reachabilityForInternetConnection; 69 | +(instancetype)reachabilityWithAddress:(void *)hostAddress; 70 | +(instancetype)reachabilityForLocalWiFi; 71 | 72 | -(instancetype)initWithReachabilityRef:(SCNetworkReachabilityRef)ref; 73 | 74 | -(BOOL)startNotifier; 75 | -(void)stopNotifier; 76 | 77 | -(BOOL)isReachable; 78 | -(BOOL)isReachableViaWWAN; 79 | -(BOOL)isReachableViaWiFi; 80 | 81 | // WWAN may be available, but not active until a connection has been established. 82 | // WiFi may require a connection for VPN on Demand. 83 | -(BOOL)isConnectionRequired; // Identical DDG variant. 84 | -(BOOL)connectionRequired; // Apple's routine. 85 | // Dynamic, on demand connection? 86 | -(BOOL)isConnectionOnDemand; 87 | // Is user intervention required? 88 | -(BOOL)isInterventionRequired; 89 | 90 | -(NetworkStatus)currentReachabilityStatus; 91 | -(SCNetworkReachabilityFlags)reachabilityFlags; 92 | -(NSString*)currentReachabilityString; 93 | -(NSString*)currentReachabilityFlags; 94 | 95 | @end 96 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/AFNetworking/AFHTTPRequestOperation.h: -------------------------------------------------------------------------------- 1 | // AFHTTPRequestOperation.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import "AFURLConnectionOperation.h" 25 | 26 | /** 27 | `AFHTTPRequestOperation` is a subclass of `AFURLConnectionOperation` for requests using the HTTP or HTTPS protocols. It encapsulates the concept of acceptable status codes and content types, which determine the success or failure of a request. 28 | */ 29 | @interface AFHTTPRequestOperation : AFURLConnectionOperation 30 | 31 | ///------------------------------------------------ 32 | /// @name Getting HTTP URL Connection Information 33 | ///------------------------------------------------ 34 | 35 | /** 36 | The last HTTP response received by the operation's connection. 37 | */ 38 | @property (readonly, nonatomic, strong) NSHTTPURLResponse *response; 39 | 40 | /** 41 | Responses sent from the server in data tasks created with `dataTaskWithRequest:success:failure:` and run using the `GET` / `POST` / et al. convenience methods are automatically validated and serialized by the response serializer. By default, this property is set to an AFHTTPResponse serializer, which uses the raw data as its response object. The serializer validates the status code to be in the `2XX` range, denoting success. If the response serializer generates an error in `-responseObjectForResponse:data:error:`, the `failure` callback of the session task or request operation will be executed; otherwise, the `success` callback will be executed. 42 | 43 | @warning `responseSerializer` must not be `nil`. Setting a response serializer will clear out any cached value 44 | */ 45 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; 46 | 47 | /** 48 | An object constructed by the `responseSerializer` from the response and response data. Returns `nil` unless the operation `isFinished`, has a `response`, and has `responseData` with non-zero content length. If an error occurs during serialization, `nil` will be returned, and the `error` property will be populated with the serialization error. 49 | */ 50 | @property (readonly, nonatomic, strong) id responseObject; 51 | 52 | ///----------------------------------------------------------- 53 | /// @name Setting Completion Block Success / Failure Callbacks 54 | ///----------------------------------------------------------- 55 | 56 | /** 57 | Sets the `completionBlock` property with a block that executes either the specified success or failure block, depending on the state of the request on completion. If `error` returns a value, which can be caused by an unacceptable status code or content type, then `failure` is executed. Otherwise, `success` is executed. 58 | 59 | This method should be overridden in subclasses in order to specify the response object passed into the success block. 60 | 61 | @param success The block to be executed on the completion of a successful request. This block has no return value and takes two arguments: the receiver operation and the object constructed from the response data of the request. 62 | @param failure The block to be executed on the completion of an unsuccessful request. This block has no return value and takes two arguments: the receiver operation and the error that occurred during the request. 63 | */ 64 | - (void)setCompletionBlockWithSuccess:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success 65 | failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure; 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | // AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import 25 | 26 | #ifndef _AFNETWORKING_ 27 | #define _AFNETWORKING_ 28 | 29 | #import "AFURLRequestSerialization.h" 30 | #import "AFURLResponseSerialization.h" 31 | #import "AFSecurityPolicy.h" 32 | #import "AFNetworkReachabilityManager.h" 33 | 34 | #import "AFURLConnectionOperation.h" 35 | #import "AFHTTPRequestOperation.h" 36 | #import "AFHTTPRequestOperationManager.h" 37 | 38 | #if ( ( defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 1090) || \ 39 | ( defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 ) ) 40 | #import "AFURLSessionManager.h" 41 | #import "AFHTTPSessionManager.h" 42 | #endif 43 | 44 | #endif /* _AFNETWORKING_ */ 45 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | // AFSecurityPolicy.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import 25 | 26 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { 27 | AFSSLPinningModeNone, 28 | AFSSLPinningModePublicKey, 29 | AFSSLPinningModeCertificate, 30 | }; 31 | 32 | /** 33 | `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. 34 | 35 | Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. 36 | */ 37 | @interface AFSecurityPolicy : NSObject 38 | 39 | /** 40 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. 41 | */ 42 | @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; 43 | 44 | /** 45 | Whether to evaluate an entire SSL certificate chain, or just the leaf certificate. Defaults to `YES`. 46 | */ 47 | @property (nonatomic, assign) BOOL validatesCertificateChain; 48 | 49 | /** 50 | The certificates used to evaluate server trust according to the SSL pinning mode. By default, this property is set to any (`.cer`) certificates included in the app bundle. 51 | */ 52 | @property (nonatomic, strong) NSArray *pinnedCertificates; 53 | 54 | /** 55 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. 56 | */ 57 | @property (nonatomic, assign) BOOL allowInvalidCertificates; 58 | 59 | /** 60 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES` for `AFSSLPinningModePublicKey` or `AFSSLPinningModeCertificate`, otherwise `NO`. 61 | */ 62 | @property (nonatomic, assign) BOOL validatesDomainName; 63 | 64 | ///----------------------------------------- 65 | /// @name Getting Specific Security Policies 66 | ///----------------------------------------- 67 | 68 | /** 69 | Returns the shared default security policy, which does not allow invalid certificates, does not validate domain name, and does not validate against pinned certificates or public keys. 70 | 71 | @return The default security policy. 72 | */ 73 | + (instancetype)defaultPolicy; 74 | 75 | ///--------------------- 76 | /// @name Initialization 77 | ///--------------------- 78 | 79 | /** 80 | Creates and returns a security policy with the specified pinning mode. 81 | 82 | @param pinningMode The SSL pinning mode. 83 | 84 | @return A new security policy. 85 | */ 86 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; 87 | 88 | ///------------------------------ 89 | /// @name Evaluating Server Trust 90 | ///------------------------------ 91 | 92 | /** 93 | Whether or not the specified server trust should be accepted, based on the security policy. 94 | 95 | This method should be used when responding to an authentication challenge from a server. 96 | 97 | @param serverTrust The X.509 certificate trust of the server. 98 | 99 | @return Whether or not to trust the server. 100 | 101 | @warning This method has been deprecated in favor of `-evaluateServerTrust:forDomain:`. 102 | */ 103 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust DEPRECATED_ATTRIBUTE; 104 | 105 | /** 106 | Whether or not the specified server trust should be accepted, based on the security policy. 107 | 108 | This method should be used when responding to an authentication challenge from a server. 109 | 110 | @param serverTrust The X.509 certificate trust of the server. 111 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated. 112 | 113 | @return Whether or not to trust the server. 114 | */ 115 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 116 | forDomain:(NSString *)domain; 117 | 118 | @end 119 | 120 | ///---------------- 121 | /// @name Constants 122 | ///---------------- 123 | 124 | /** 125 | ## SSL Pinning Modes 126 | 127 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. 128 | 129 | enum { 130 | AFSSLPinningModeNone, 131 | AFSSLPinningModePublicKey, 132 | AFSSLPinningModeCertificate, 133 | } 134 | 135 | `AFSSLPinningModeNone` 136 | Do not used pinned certificates to validate servers. 137 | 138 | `AFSSLPinningModePublicKey` 139 | Validate host certificates against public keys of pinned certificates. 140 | 141 | `AFSSLPinningModeCertificate` 142 | Validate host certificates against pinned certificates. 143 | */ 144 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/HTMLString/GTMNSString+HTML.h: -------------------------------------------------------------------------------- 1 | // 2 | // GTMNSString+HTML.h 3 | // Dealing with NSStrings that contain HTML 4 | // 5 | // Copyright 2006-2008 Google Inc. 6 | // 7 | // Licensed under the Apache License, Version 2.0 (the "License"); you may not 8 | // use this file except in compliance with the License. You may obtain a copy 9 | // of the License at 10 | // 11 | // http://www.apache.org/licenses/LICENSE-2.0 12 | // 13 | // Unless required by applicable law or agreed to in writing, software 14 | // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 15 | // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 16 | // License for the specific language governing permissions and limitations under 17 | // the License. 18 | // 19 | 20 | #import 21 | 22 | /// Utilities for NSStrings containing HTML 23 | @interface NSString (GTMNSStringHTMLAdditions) 24 | 25 | /// Get a string where internal characters that need escaping for HTML are escaped 26 | // 27 | /// For example, '&' become '&'. This will only cover characters from table 28 | /// A.2.2 of http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_Special_characters 29 | /// which is what you want for a unicode encoded webpage. If you have a ascii 30 | /// or non-encoded webpage, please use stringByEscapingAsciiHTML which will 31 | /// encode all characters. 32 | /// 33 | /// For obvious reasons this call is only safe once. 34 | // 35 | // Returns: 36 | // Autoreleased NSString 37 | // 38 | - (NSString *)gtm_stringByEscapingForHTML; 39 | 40 | /// Get a string where internal characters that need escaping for HTML are escaped 41 | // 42 | /// For example, '&' become '&' 43 | /// All non-mapped characters (unicode that don't have a &keyword; mapping) 44 | /// will be converted to the appropriate &#xxx; value. If your webpage is 45 | /// unicode encoded (UTF16 or UTF8) use stringByEscapingHTML instead as it is 46 | /// faster, and produces less bloated and more readable HTML (as long as you 47 | /// are using a unicode compliant HTML reader). 48 | /// 49 | /// For obvious reasons this call is only safe once. 50 | // 51 | // Returns: 52 | // Autoreleased NSString 53 | // 54 | - (NSString *)gtm_stringByEscapingForAsciiHTML; 55 | 56 | /// Get a string where internal characters that are escaped for HTML are unescaped 57 | // 58 | /// For example, '&' becomes '&' 59 | /// Handles and 2 cases as well 60 | /// 61 | // Returns: 62 | // Autoreleased NSString 63 | // 64 | - (NSString *)gtm_stringByUnescapingFromHTML; 65 | 66 | @end -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/HTMLString/NSString+HTML.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+HTML.h 3 | // MWFeedParser 4 | // 5 | // Copyright (c) 2010 Michael Waterfall 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // 14 | // 1. The above copyright notice and this permission notice shall be included 15 | // in all copies or substantial portions of the Software. 16 | // 17 | // 2. This Software cannot be used to archive or collect data such as (but not 18 | // limited to) that of events, news, experiences and activities, for the 19 | // purpose of any concept relating to diary/journal keeping. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | // THE SOFTWARE. 28 | // 29 | 30 | #import 31 | 32 | // Dependant upon GTMNSString+HTML 33 | 34 | @interface NSString (HTML) 35 | 36 | // Strips HTML tags & comments, removes extra whitespace and decodes HTML character entities. 37 | - (NSString *)stringByConvertingHTMLToPlainText; 38 | 39 | // Decode all HTML entities using GTM. 40 | - (NSString *)stringByDecodingHTMLEntities; 41 | 42 | // Encode all HTML entities using GTM. 43 | - (NSString *)stringByEncodingHTMLEntities; 44 | 45 | // Minimal unicode encoding will only cover characters from table 46 | // A.2.2 of http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_Special_characters 47 | // which is what you want for a unicode encoded webpage. 48 | - (NSString *)stringByEncodingHTMLEntities:(BOOL)isUnicode; 49 | 50 | // Replace newlines with
tags. 51 | - (NSString *)stringWithNewLinesAsBRs; 52 | 53 | // Remove newlines and white space from string. 54 | - (NSString *)stringByRemovingNewLinesAndWhitespace; 55 | 56 | // Wrap plain URLs in ... 57 | // - Ignores URLs inside tags (any URL beginning with =") 58 | // - HTTP & HTTPS schemes only 59 | // - Only works in iOS 4+ as we use NSRegularExpression (returns self if not supported so be careful with NSMutableStrings) 60 | // - Expression: (? 10 | #import "MFSideMenuShadow.h" 11 | 12 | extern NSString * const MFSideMenuStateNotificationEvent; 13 | 14 | typedef enum { 15 | MFSideMenuPanModeNone = 0, // pan disabled 16 | MFSideMenuPanModeCenterViewController = 1 << 0, // enable panning on the centerViewController 17 | MFSideMenuPanModeSideMenu = 1 << 1, // enable panning on side menus 18 | MFSideMenuPanModeDefault = MFSideMenuPanModeCenterViewController | MFSideMenuPanModeSideMenu 19 | } MFSideMenuPanMode; 20 | 21 | typedef enum { 22 | MFSideMenuStateClosed, // the menu is closed 23 | MFSideMenuStateLeftMenuOpen, // the left-hand menu is open 24 | MFSideMenuStateRightMenuOpen // the right-hand menu is open 25 | } MFSideMenuState; 26 | 27 | typedef enum { 28 | MFSideMenuStateEventMenuWillOpen, // the menu is going to open 29 | MFSideMenuStateEventMenuDidOpen, // the menu finished opening 30 | MFSideMenuStateEventMenuWillClose, // the menu is going to close 31 | MFSideMenuStateEventMenuDidClose // the menu finished closing 32 | } MFSideMenuStateEvent; 33 | 34 | 35 | @interface MFSideMenuContainerViewController : UIViewController 36 | 37 | + (MFSideMenuContainerViewController *)containerWithCenterViewController:(id)centerViewController 38 | leftMenuViewController:(id)leftMenuViewController 39 | rightMenuViewController:(id)rightMenuViewController; 40 | 41 | @property (nonatomic, strong) id centerViewController; 42 | @property (nonatomic, strong) UIViewController *leftMenuViewController; 43 | @property (nonatomic, strong) UIViewController *rightMenuViewController; 44 | 45 | @property (nonatomic, assign) MFSideMenuState menuState; 46 | @property (nonatomic, assign) MFSideMenuPanMode panMode; 47 | 48 | // menu open/close animation duration -- user can pan faster than default duration, max duration sets the limit 49 | @property (nonatomic, assign) CGFloat menuAnimationDefaultDuration; 50 | @property (nonatomic, assign) CGFloat menuAnimationMaxDuration; 51 | 52 | // width of the side menus 53 | @property (nonatomic, assign) CGFloat menuWidth; 54 | @property (nonatomic, assign) CGFloat leftMenuWidth; 55 | @property (nonatomic, assign) CGFloat rightMenuWidth; 56 | 57 | // shadow 58 | @property (nonatomic, strong) MFSideMenuShadow *shadow; 59 | 60 | // menu slide-in animation 61 | @property (nonatomic, assign) BOOL menuSlideAnimationEnabled; 62 | @property (nonatomic, assign) CGFloat menuSlideAnimationFactor; // higher = less menu movement on animation 63 | 64 | 65 | - (void)toggleLeftSideMenuCompletion:(void (^)(void))completion; 66 | - (void)toggleRightSideMenuCompletion:(void (^)(void))completion; 67 | - (void)setMenuState:(MFSideMenuState)menuState completion:(void (^)(void))completion; 68 | - (void)setMenuWidth:(CGFloat)menuWidth animated:(BOOL)animated; 69 | - (void)setLeftMenuWidth:(CGFloat)leftMenuWidth animated:(BOOL)animated; 70 | - (void)setRightMenuWidth:(CGFloat)rightMenuWidth animated:(BOOL)animated; 71 | 72 | // can be used to attach a pan gesture recognizer to a custom view 73 | - (UIPanGestureRecognizer *)panGestureRecognizer; 74 | 75 | @end -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/MFSideMenu/MFSideMenuShadow.h: -------------------------------------------------------------------------------- 1 | // 2 | // MFSideMenuShadow.h 3 | // MFSideMenuDemoSearchBar 4 | // 5 | // Created by Michael Frederick on 5/13/13. 6 | // Copyright (c) 2013 Frederick Development. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface MFSideMenuShadow : NSObject 13 | 14 | @property (nonatomic, assign) BOOL enabled; 15 | @property (nonatomic, assign) CGFloat radius; 16 | @property (nonatomic, assign) CGFloat opacity; 17 | @property (nonatomic, strong) UIColor *color; 18 | @property (nonatomic, assign) UIView *shadowedView; 19 | 20 | + (MFSideMenuShadow *)shadowWithView:(UIView *)shadowedView; 21 | + (MFSideMenuShadow *)shadowWithColor:(UIColor *)color radius:(CGFloat)radius opacity:(CGFloat)opacity; 22 | 23 | - (void)draw; 24 | - (void)shadowedViewWillRotate; 25 | - (void)shadowedViewDidRotate; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/MFSideMenu/MFSideMenuShadow.m: -------------------------------------------------------------------------------- 1 | // 2 | // MFSideMenuShadow.m 3 | // MFSideMenuDemoSearchBar 4 | // 5 | // Created by Michael Frederick on 5/13/13. 6 | // Copyright (c) 2013 Frederick Development. All rights reserved. 7 | // 8 | 9 | #import "MFSideMenuShadow.h" 10 | #import 11 | 12 | @implementation MFSideMenuShadow 13 | 14 | @synthesize color = _color; 15 | @synthesize opacity = _opacity; 16 | @synthesize radius = _radius; 17 | @synthesize enabled = _enabled; 18 | @synthesize shadowedView; 19 | 20 | + (MFSideMenuShadow *)shadowWithView:(UIView *)shadowedView { 21 | MFSideMenuShadow *shadow = [MFSideMenuShadow shadowWithColor:[UIColor blackColor] radius:10.0f opacity:0.75f]; 22 | shadow.shadowedView = shadowedView; 23 | return shadow; 24 | } 25 | 26 | + (MFSideMenuShadow *)shadowWithColor:(UIColor *)color radius:(CGFloat)radius opacity:(CGFloat)opacity { 27 | MFSideMenuShadow *shadow = [MFSideMenuShadow new]; 28 | shadow.color = color; 29 | shadow.radius = radius; 30 | shadow.opacity = opacity; 31 | return shadow; 32 | } 33 | 34 | - (id)init { 35 | self = [super init]; 36 | if(self) { 37 | self.color = [UIColor blackColor]; 38 | self.opacity = 0.75f; 39 | self.radius = 10.0f; 40 | self.enabled = YES; 41 | } 42 | return self; 43 | } 44 | 45 | 46 | #pragma mark - 47 | #pragma mark - Property Setters 48 | 49 | - (void)setEnabled:(BOOL)shadowEnabled { 50 | _enabled = shadowEnabled; 51 | [self draw]; 52 | } 53 | 54 | - (void)setRadius:(CGFloat)shadowRadius { 55 | _radius = shadowRadius; 56 | [self draw]; 57 | } 58 | 59 | - (void)setColor:(UIColor *)shadowColor { 60 | _color = shadowColor; 61 | [self draw]; 62 | } 63 | 64 | - (void)setOpacity:(CGFloat)shadowOpacity { 65 | _opacity = shadowOpacity; 66 | [self draw]; 67 | } 68 | 69 | 70 | #pragma mark - 71 | #pragma mark - Drawing 72 | 73 | - (void)draw { 74 | if(_enabled) { 75 | [self show]; 76 | } else { 77 | [self hide]; 78 | } 79 | } 80 | 81 | - (void)show { 82 | CGRect pathRect = self.shadowedView.bounds; 83 | pathRect.size = self.shadowedView.frame.size; 84 | self.shadowedView.layer.shadowPath = [UIBezierPath bezierPathWithRect:pathRect].CGPath; 85 | self.shadowedView.layer.shadowOpacity = self.opacity; 86 | self.shadowedView.layer.shadowRadius = self.radius; 87 | self.shadowedView.layer.shadowColor = [self.color CGColor]; 88 | self.shadowedView.layer.rasterizationScale = [[UIScreen mainScreen] scale]; 89 | } 90 | 91 | - (void)hide { 92 | self.shadowedView.layer.shadowOpacity = 0.0f; 93 | self.shadowedView.layer.shadowRadius = 0.0f; 94 | } 95 | 96 | 97 | #pragma mark - 98 | #pragma mark - ShadowedView Rotation 99 | 100 | - (void)shadowedViewWillRotate { 101 | self.shadowedView.layer.shadowPath = nil; 102 | self.shadowedView.layer.shouldRasterize = YES; 103 | } 104 | 105 | - (void)shadowedViewDidRotate { 106 | [self draw]; 107 | self.shadowedView.layer.shouldRasterize = NO; 108 | } 109 | 110 | @end 111 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/MFSideMenu/UIViewController+MFSideMenuAdditions.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MFSideMenuAdditions.h 3 | // MFSideMenuDemoBasic 4 | // 5 | // Created by Michael Frederick on 4/2/13. 6 | // Copyright (c) 2013 Frederick Development. All rights reserved. 7 | // 8 | 9 | #import 10 | @class MFSideMenuContainerViewController; 11 | 12 | // category on UIViewController to provide reference to the menuContainerViewController in any of the contained View Controllers 13 | @interface UIViewController (MFSideMenuAdditions) 14 | 15 | @property(nonatomic,readonly,retain) MFSideMenuContainerViewController *menuContainerViewController; 16 | 17 | @end 18 | 19 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/MFSideMenu/UIViewController+MFSideMenuAdditions.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewController+MFSideMenuAdditions.m 3 | // MFSideMenuDemoBasic 4 | // 5 | // Created by Michael Frederick on 4/2/13. 6 | // Copyright (c) 2013 Frederick Development. All rights reserved. 7 | // 8 | 9 | #import "UIViewController+MFSideMenuAdditions.h" 10 | #import "MFSideMenuContainerViewController.h" 11 | 12 | @implementation UIViewController (MFSideMenuAdditions) 13 | 14 | @dynamic menuContainerViewController; 15 | 16 | - (MFSideMenuContainerViewController *)menuContainerViewController { 17 | id containerView = self; 18 | while (![containerView isKindOfClass:[MFSideMenuContainerViewController class]] && containerView) { 19 | if ([containerView respondsToSelector:@selector(parentViewController)]) 20 | containerView = [containerView parentViewController]; 21 | if ([containerView respondsToSelector:@selector(splitViewController)] && !containerView) 22 | containerView = [containerView splitViewController]; 23 | } 24 | return containerView; 25 | } 26 | 27 | @end -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/MKAnnotationView+WebCache.h: -------------------------------------------------------------------------------- 1 | // 2 | // MKAnnotationView+WebCache.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 14/03/12. 6 | // Copyright (c) 2012 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "MapKit/MapKit.h" 10 | #import "SDWebImageManager.h" 11 | 12 | /** 13 | * Integrates SDWebImage async downloading and caching of remote images with MKAnnotationView. 14 | */ 15 | @interface MKAnnotationView (WebCache) 16 | 17 | /** 18 | * Get the current image URL. 19 | * 20 | * Note that because of the limitations of categories this property can get out of sync 21 | * if you use sd_setImage: directly. 22 | */ 23 | - (NSURL *)sd_imageURL; 24 | 25 | /** 26 | * Set the imageView `image` with an `url`. 27 | * 28 | * The download is asynchronous and cached. 29 | * 30 | * @param url The url for the image. 31 | */ 32 | - (void)sd_setImageWithURL:(NSURL *)url; 33 | 34 | /** 35 | * Set the imageView `image` with an `url` and a placeholder. 36 | * 37 | * The download is asynchronous and cached. 38 | * 39 | * @param url The url for the image. 40 | * @param placeholder The image to be set initially, until the image request finishes. 41 | * @see sd_setImageWithURL:placeholderImage:options: 42 | */ 43 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder; 44 | 45 | /** 46 | * Set the imageView `image` with an `url`, placeholder and custom options. 47 | * 48 | * The download is asynchronous and cached. 49 | * 50 | * @param url The url for the image. 51 | * @param placeholder The image to be set initially, until the image request finishes. 52 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 53 | */ 54 | 55 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options; 56 | 57 | /** 58 | * Set the imageView `image` with an `url`. 59 | * 60 | * The download is asynchronous and cached. 61 | * 62 | * @param url The url for the image. 63 | * @param completedBlock A block called when operation has been completed. This block has no return value 64 | * and takes the requested UIImage as first parameter. In case of error the image parameter 65 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 66 | * indicating if the image was retrived from the local cache or from the network. 67 | * The fourth parameter is the original image url. 68 | */ 69 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; 70 | 71 | /** 72 | * Set the imageView `image` with an `url`, placeholder. 73 | * 74 | * The download is asynchronous and cached. 75 | * 76 | * @param url The url for the image. 77 | * @param placeholder The image to be set initially, until the image request finishes. 78 | * @param completedBlock A block called when operation has been completed. This block has no return value 79 | * and takes the requested UIImage as first parameter. In case of error the image parameter 80 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 81 | * indicating if the image was retrived from the local cache or from the network. 82 | * The fourth parameter is the original image url. 83 | */ 84 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock; 85 | 86 | /** 87 | * Set the imageView `image` with an `url`, placeholder and custom options. 88 | * 89 | * The download is asynchronous and cached. 90 | * 91 | * @param url The url for the image. 92 | * @param placeholder The image to be set initially, until the image request finishes. 93 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 94 | * @param completedBlock A block called when operation has been completed. This block has no return value 95 | * and takes the requested UIImage as first parameter. In case of error the image parameter 96 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 97 | * indicating if the image was retrived from the local cache or from the network. 98 | * The fourth parameter is the original image url. 99 | */ 100 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 101 | 102 | /** 103 | * Cancel the current download 104 | */ 105 | - (void)sd_cancelCurrentImageLoad; 106 | 107 | @end 108 | 109 | 110 | @interface MKAnnotationView (WebCacheDeprecated) 111 | 112 | - (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`"); 113 | 114 | - (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); 115 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); 116 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:`"); 117 | 118 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:completed:`"); 119 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`"); 120 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); 121 | 122 | - (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`"); 123 | 124 | @end 125 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/MKAnnotationView+WebCache.m: -------------------------------------------------------------------------------- 1 | // 2 | // MKAnnotationView+WebCache.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 14/03/12. 6 | // Copyright (c) 2012 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "MKAnnotationView+WebCache.h" 10 | #import "objc/runtime.h" 11 | #import "UIView+WebCacheOperation.h" 12 | 13 | static char imageURLKey; 14 | 15 | @implementation MKAnnotationView (WebCache) 16 | 17 | - (NSURL *)sd_imageURL { 18 | return objc_getAssociatedObject(self, &imageURLKey); 19 | } 20 | 21 | - (void)sd_setImageWithURL:(NSURL *)url { 22 | [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil]; 23 | } 24 | 25 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { 26 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:nil]; 27 | } 28 | 29 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 30 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options completed:nil]; 31 | } 32 | 33 | - (void)sd_setImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { 34 | [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:completedBlock]; 35 | } 36 | 37 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletionBlock)completedBlock { 38 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:completedBlock]; 39 | } 40 | 41 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 42 | [self sd_cancelCurrentImageLoad]; 43 | 44 | objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 45 | self.image = placeholder; 46 | 47 | if (url) { 48 | __weak __typeof(self)wself = self; 49 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 50 | if (!wself) return; 51 | dispatch_main_sync_safe(^{ 52 | __strong MKAnnotationView *sself = wself; 53 | if (!sself) return; 54 | if (image) { 55 | sself.image = image; 56 | } 57 | if (completedBlock && finished) { 58 | completedBlock(image, error, cacheType, url); 59 | } 60 | }); 61 | }]; 62 | [self sd_setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"]; 63 | } else { 64 | dispatch_main_async_safe(^{ 65 | NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 66 | if (completedBlock) { 67 | completedBlock(nil, error, SDImageCacheTypeNone, url); 68 | } 69 | }); 70 | } 71 | } 72 | 73 | - (void)sd_cancelCurrentImageLoad { 74 | [self sd_cancelImageLoadOperationWithKey:@"MKAnnotationViewImage"]; 75 | } 76 | 77 | @end 78 | 79 | 80 | @implementation MKAnnotationView (WebCacheDeprecated) 81 | 82 | - (NSURL *)imageURL { 83 | return [self sd_imageURL]; 84 | } 85 | 86 | - (void)setImageWithURL:(NSURL *)url { 87 | [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil]; 88 | } 89 | 90 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder { 91 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:nil]; 92 | } 93 | 94 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options { 95 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options completed:nil]; 96 | } 97 | 98 | - (void)setImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { 99 | [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 100 | if (completedBlock) { 101 | completedBlock(image, error, cacheType); 102 | } 103 | }]; 104 | } 105 | 106 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock { 107 | [self sd_setImageWithURL:url placeholderImage:placeholder options:0 completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 108 | if (completedBlock) { 109 | completedBlock(image, error, cacheType); 110 | } 111 | }]; 112 | } 113 | 114 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 115 | [self sd_setImageWithURL:url placeholderImage:placeholder options:options completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 116 | if (completedBlock) { 117 | completedBlock(image, error, cacheType); 118 | } 119 | }]; 120 | } 121 | 122 | - (void)cancelCurrentImageLoad { 123 | [self sd_cancelCurrentImageLoad]; 124 | } 125 | 126 | @end 127 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/NSData+ImageContentType.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Fabrice Aneche on 06/01/14. 3 | // Copyright (c) 2014 Dailymotion. All rights reserved. 4 | // 5 | 6 | #import 7 | 8 | @interface NSData (ImageContentType) 9 | 10 | /** 11 | * Compute the content type for an image data 12 | * 13 | * @param data the input data 14 | * 15 | * @return the content type as string (i.e. image/jpeg, image/gif) 16 | */ 17 | + (NSString *)sd_contentTypeForImageData:(NSData *)data; 18 | 19 | @end 20 | 21 | 22 | @interface NSData (ImageContentTypeDeprecated) 23 | 24 | + (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`"); 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/NSData+ImageContentType.m: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Fabrice Aneche on 06/01/14. 3 | // Copyright (c) 2014 Dailymotion. All rights reserved. 4 | // 5 | 6 | #import "NSData+ImageContentType.h" 7 | 8 | 9 | @implementation NSData (ImageContentType) 10 | 11 | + (NSString *)sd_contentTypeForImageData:(NSData *)data { 12 | uint8_t c; 13 | [data getBytes:&c length:1]; 14 | switch (c) { 15 | case 0xFF: 16 | return @"image/jpeg"; 17 | case 0x89: 18 | return @"image/png"; 19 | case 0x47: 20 | return @"image/gif"; 21 | case 0x49: 22 | case 0x4D: 23 | return @"image/tiff"; 24 | case 0x52: 25 | // R as RIFF for WEBP 26 | if ([data length] < 12) { 27 | return nil; 28 | } 29 | 30 | NSString *testString = [[NSString alloc] initWithData:[data subdataWithRange:NSMakeRange(0, 12)] encoding:NSASCIIStringEncoding]; 31 | if ([testString hasPrefix:@"RIFF"] && [testString hasSuffix:@"WEBP"]) { 32 | return @"image/webp"; 33 | } 34 | 35 | return nil; 36 | } 37 | return nil; 38 | } 39 | 40 | @end 41 | 42 | 43 | @implementation NSData (ImageContentTypeDeprecated) 44 | 45 | + (NSString *)contentTypeForImageData:(NSData *)data { 46 | return [self sd_contentTypeForImageData:data]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/SDWebImageCompat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * (c) Jamie Pinkham 5 | * 6 | * For the full copyright and license information, please view the LICENSE 7 | * file that was distributed with this source code. 8 | */ 9 | 10 | #import 11 | 12 | #ifdef __OBJC_GC__ 13 | #error SDWebImage does not support Objective-C Garbage Collection 14 | #endif 15 | 16 | #if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_5_0 17 | #error SDWebImage doesn't support Deployement Target version < 5.0 18 | #endif 19 | 20 | #if !TARGET_OS_IPHONE 21 | #import 22 | #ifndef UIImage 23 | #define UIImage NSImage 24 | #endif 25 | #ifndef UIImageView 26 | #define UIImageView NSImageView 27 | #endif 28 | #else 29 | 30 | #import 31 | 32 | #endif 33 | 34 | #ifndef NS_ENUM 35 | #define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type 36 | #endif 37 | 38 | #ifndef NS_OPTIONS 39 | #define NS_OPTIONS(_type, _name) enum _name : _type _name; enum _name : _type 40 | #endif 41 | 42 | #if OS_OBJECT_USE_OBJC 43 | #undef SDDispatchQueueRelease 44 | #undef SDDispatchQueueSetterSementics 45 | #define SDDispatchQueueRelease(q) 46 | #define SDDispatchQueueSetterSementics strong 47 | #else 48 | #undef SDDispatchQueueRelease 49 | #undef SDDispatchQueueSetterSementics 50 | #define SDDispatchQueueRelease(q) (dispatch_release(q)) 51 | #define SDDispatchQueueSetterSementics assign 52 | #endif 53 | 54 | extern UIImage *SDScaledImageForKey(NSString *key, UIImage *image); 55 | 56 | typedef void(^SDWebImageNoParamsBlock)(); 57 | 58 | extern NSString *const SDWebImageErrorDomain; 59 | 60 | #define dispatch_main_sync_safe(block)\ 61 | if ([NSThread isMainThread]) {\ 62 | block();\ 63 | } else {\ 64 | dispatch_sync(dispatch_get_main_queue(), block);\ 65 | } 66 | 67 | #define dispatch_main_async_safe(block)\ 68 | if ([NSThread isMainThread]) {\ 69 | block();\ 70 | } else {\ 71 | dispatch_async(dispatch_get_main_queue(), block);\ 72 | } 73 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/SDWebImageCompat.m: -------------------------------------------------------------------------------- 1 | // 2 | // SDWebImageCompat.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 11/12/12. 6 | // Copyright (c) 2012 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "SDWebImageCompat.h" 10 | 11 | #if !__has_feature(objc_arc) 12 | #error SDWebImage is ARC only. Either turn on ARC for the project or use -fobjc-arc flag 13 | #endif 14 | 15 | inline UIImage *SDScaledImageForKey(NSString *key, UIImage *image) { 16 | if (!image) { 17 | return nil; 18 | } 19 | 20 | if ([image.images count] > 0) { 21 | NSMutableArray *scaledImages = [NSMutableArray array]; 22 | 23 | for (UIImage *tempImage in image.images) { 24 | [scaledImages addObject:SDScaledImageForKey(key, tempImage)]; 25 | } 26 | 27 | return [UIImage animatedImageWithImages:scaledImages duration:image.duration]; 28 | } 29 | else { 30 | if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) { 31 | CGFloat scale = 1.0; 32 | if (key.length >= 8) { 33 | // Search @2x. or @3x. at the end of the string, before a 3 to 4 extension length (only if key len is 8 or more @2x./@3x. + 4 len ext) 34 | NSRange range = [key rangeOfString:@"@2x." options:0 range:NSMakeRange(key.length - 8, 5)]; 35 | if (range.location != NSNotFound) { 36 | scale = 2.0; 37 | } 38 | 39 | range = [key rangeOfString:@"@3x." options:0 range:NSMakeRange(key.length - 8, 5)]; 40 | if (range.location != NSNotFound) { 41 | scale = 3.0; 42 | } 43 | } 44 | 45 | UIImage *scaledImage = [[UIImage alloc] initWithCGImage:image.CGImage scale:scale orientation:image.imageOrientation]; 46 | image = scaledImage; 47 | } 48 | return image; 49 | } 50 | } 51 | 52 | NSString *const SDWebImageErrorDomain = @"SDWebImageErrorDomain"; 53 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/SDWebImageDecoder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * Created by james on 9/28/11. 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | #import 12 | #import "SDWebImageCompat.h" 13 | 14 | @interface UIImage (ForceDecode) 15 | 16 | + (UIImage *)decodedImageWithImage:(UIImage *)image; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/SDWebImageDecoder.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * Created by james on 9/28/11. 6 | * 7 | * For the full copyright and license information, please view the LICENSE 8 | * file that was distributed with this source code. 9 | */ 10 | 11 | #import "SDWebImageDecoder.h" 12 | 13 | @implementation UIImage (ForceDecode) 14 | 15 | + (UIImage *)decodedImageWithImage:(UIImage *)image { 16 | if (image.images) { 17 | // Do not decode animated images 18 | return image; 19 | } 20 | 21 | CGImageRef imageRef = image.CGImage; 22 | CGSize imageSize = CGSizeMake(CGImageGetWidth(imageRef), CGImageGetHeight(imageRef)); 23 | CGRect imageRect = (CGRect){.origin = CGPointZero, .size = imageSize}; 24 | 25 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); 26 | CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); 27 | 28 | int infoMask = (bitmapInfo & kCGBitmapAlphaInfoMask); 29 | BOOL anyNonAlpha = (infoMask == kCGImageAlphaNone || 30 | infoMask == kCGImageAlphaNoneSkipFirst || 31 | infoMask == kCGImageAlphaNoneSkipLast); 32 | 33 | // CGBitmapContextCreate doesn't support kCGImageAlphaNone with RGB. 34 | // https://developer.apple.com/library/mac/#qa/qa1037/_index.html 35 | if (infoMask == kCGImageAlphaNone && CGColorSpaceGetNumberOfComponents(colorSpace) > 1) { 36 | // Unset the old alpha info. 37 | bitmapInfo &= ~kCGBitmapAlphaInfoMask; 38 | 39 | // Set noneSkipFirst. 40 | bitmapInfo |= kCGImageAlphaNoneSkipFirst; 41 | } 42 | // Some PNGs tell us they have alpha but only 3 components. Odd. 43 | else if (!anyNonAlpha && CGColorSpaceGetNumberOfComponents(colorSpace) == 3) { 44 | // Unset the old alpha info. 45 | bitmapInfo &= ~kCGBitmapAlphaInfoMask; 46 | bitmapInfo |= kCGImageAlphaPremultipliedFirst; 47 | } 48 | 49 | // It calculates the bytes-per-row based on the bitsPerComponent and width arguments. 50 | CGContextRef context = CGBitmapContextCreate(NULL, 51 | imageSize.width, 52 | imageSize.height, 53 | CGImageGetBitsPerComponent(imageRef), 54 | 0, 55 | colorSpace, 56 | bitmapInfo); 57 | CGColorSpaceRelease(colorSpace); 58 | 59 | // If failed, return undecompressed image 60 | if (!context) return image; 61 | 62 | CGContextDrawImage(context, imageRect, imageRef); 63 | CGImageRef decompressedImageRef = CGBitmapContextCreateImage(context); 64 | 65 | CGContextRelease(context); 66 | 67 | UIImage *decompressedImage = [UIImage imageWithCGImage:decompressedImageRef scale:image.scale orientation:image.imageOrientation]; 68 | CGImageRelease(decompressedImageRef); 69 | return decompressedImage; 70 | } 71 | 72 | @end 73 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/SDWebImageDownloaderOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageDownloader.h" 11 | #import "SDWebImageOperation.h" 12 | 13 | extern NSString *const SDWebImageDownloadStartNotification; 14 | extern NSString *const SDWebImageDownloadReceiveResponseNotification; 15 | extern NSString *const SDWebImageDownloadStopNotification; 16 | extern NSString *const SDWebImageDownloadFinishNotification; 17 | 18 | @interface SDWebImageDownloaderOperation : NSOperation 19 | 20 | /** 21 | * The request used by the operation's connection. 22 | */ 23 | @property (strong, nonatomic, readonly) NSURLRequest *request; 24 | 25 | 26 | @property (assign, nonatomic) BOOL shouldDecompressImages; 27 | 28 | /** 29 | * Whether the URL connection should consult the credential storage for authenticating the connection. `YES` by default. 30 | * 31 | * This is the value that is returned in the `NSURLConnectionDelegate` method `-connectionShouldUseCredentialStorage:`. 32 | */ 33 | @property (nonatomic, assign) BOOL shouldUseCredentialStorage; 34 | 35 | /** 36 | * The credential used for authentication challenges in `-connection:didReceiveAuthenticationChallenge:`. 37 | * 38 | * This will be overridden by any shared credentials that exist for the username or password of the request URL, if present. 39 | */ 40 | @property (nonatomic, strong) NSURLCredential *credential; 41 | 42 | /** 43 | * The SDWebImageDownloaderOptions for the receiver. 44 | */ 45 | @property (assign, nonatomic, readonly) SDWebImageDownloaderOptions options; 46 | 47 | /** 48 | * The expected size of data. 49 | */ 50 | @property (assign, nonatomic) NSInteger expectedSize; 51 | 52 | /** 53 | * The response returned by the operation's connection. 54 | */ 55 | @property (strong, nonatomic) NSURLResponse *response; 56 | 57 | /** 58 | * Initializes a `SDWebImageDownloaderOperation` object 59 | * 60 | * @see SDWebImageDownloaderOperation 61 | * 62 | * @param request the URL request 63 | * @param options downloader options 64 | * @param progressBlock the block executed when a new chunk of data arrives. 65 | * @note the progress block is executed on a background queue 66 | * @param completedBlock the block executed when the download is done. 67 | * @note the completed block is executed on the main queue for success. If errors are found, there is a chance the block will be executed on a background queue 68 | * @param cancelBlock the block executed if the download (operation) is cancelled 69 | * 70 | * @return the initialized instance 71 | */ 72 | - (id)initWithRequest:(NSURLRequest *)request 73 | options:(SDWebImageDownloaderOptions)options 74 | progress:(SDWebImageDownloaderProgressBlock)progressBlock 75 | completed:(SDWebImageDownloaderCompletedBlock)completedBlock 76 | cancelled:(SDWebImageNoParamsBlock)cancelBlock; 77 | 78 | @end 79 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/SDWebImageOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | 11 | @protocol SDWebImageOperation 12 | 13 | - (void)cancel; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/SDWebImagePrefetcher.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageManager.h" 11 | 12 | @class SDWebImagePrefetcher; 13 | 14 | @protocol SDWebImagePrefetcherDelegate 15 | 16 | @optional 17 | 18 | /** 19 | * Called when an image was prefetched. 20 | * 21 | * @param imagePrefetcher The current image prefetcher 22 | * @param imageURL The image url that was prefetched 23 | * @param finishedCount The total number of images that were prefetched (successful or not) 24 | * @param totalCount The total number of images that were to be prefetched 25 | */ 26 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didPrefetchURL:(NSURL *)imageURL finishedCount:(NSUInteger)finishedCount totalCount:(NSUInteger)totalCount; 27 | 28 | /** 29 | * Called when all images are prefetched. 30 | * @param imagePrefetcher The current image prefetcher 31 | * @param totalCount The total number of images that were prefetched (whether successful or not) 32 | * @param skippedCount The total number of images that were skipped 33 | */ 34 | - (void)imagePrefetcher:(SDWebImagePrefetcher *)imagePrefetcher didFinishWithTotalCount:(NSUInteger)totalCount skippedCount:(NSUInteger)skippedCount; 35 | 36 | @end 37 | 38 | typedef void(^SDWebImagePrefetcherProgressBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfTotalUrls); 39 | typedef void(^SDWebImagePrefetcherCompletionBlock)(NSUInteger noOfFinishedUrls, NSUInteger noOfSkippedUrls); 40 | 41 | /** 42 | * Prefetch some URLs in the cache for future use. Images are downloaded in low priority. 43 | */ 44 | @interface SDWebImagePrefetcher : NSObject 45 | 46 | /** 47 | * The web image manager 48 | */ 49 | @property (strong, nonatomic, readonly) SDWebImageManager *manager; 50 | 51 | /** 52 | * Maximum number of URLs to prefetch at the same time. Defaults to 3. 53 | */ 54 | @property (nonatomic, assign) NSUInteger maxConcurrentDownloads; 55 | 56 | /** 57 | * SDWebImageOptions for prefetcher. Defaults to SDWebImageLowPriority. 58 | */ 59 | @property (nonatomic, assign) SDWebImageOptions options; 60 | 61 | /** 62 | * Queue options for Prefetcher. Defaults to Main Queue. 63 | */ 64 | @property (nonatomic, assign) dispatch_queue_t prefetcherQueue; 65 | 66 | @property (weak, nonatomic) id delegate; 67 | 68 | /** 69 | * Return the global image prefetcher instance. 70 | */ 71 | + (SDWebImagePrefetcher *)sharedImagePrefetcher; 72 | 73 | /** 74 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 75 | * currently one image is downloaded at a time, 76 | * and skips images for failed downloads and proceed to the next image in the list 77 | * 78 | * @param urls list of URLs to prefetch 79 | */ 80 | - (void)prefetchURLs:(NSArray *)urls; 81 | 82 | /** 83 | * Assign list of URLs to let SDWebImagePrefetcher to queue the prefetching, 84 | * currently one image is downloaded at a time, 85 | * and skips images for failed downloads and proceed to the next image in the list 86 | * 87 | * @param urls list of URLs to prefetch 88 | * @param progressBlock block to be called when progress updates; 89 | * first parameter is the number of completed (successful or not) requests, 90 | * second parameter is the total number of images originally requested to be prefetched 91 | * @param completionBlock block to be called when prefetching is completed 92 | * first param is the number of completed (successful or not) requests, 93 | * second parameter is the number of skipped requests 94 | */ 95 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock; 96 | 97 | /** 98 | * Remove and cancel queued list 99 | */ 100 | - (void)cancelPrefetching; 101 | 102 | 103 | @end 104 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/SDWebImagePrefetcher.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "SDWebImagePrefetcher.h" 10 | 11 | #if (!defined(DEBUG) && !defined (SD_VERBOSE)) || defined(SD_LOG_NONE) 12 | #define NSLog(...) 13 | #endif 14 | 15 | @interface SDWebImagePrefetcher () 16 | 17 | @property (strong, nonatomic) SDWebImageManager *manager; 18 | @property (strong, nonatomic) NSArray *prefetchURLs; 19 | @property (assign, nonatomic) NSUInteger requestedCount; 20 | @property (assign, nonatomic) NSUInteger skippedCount; 21 | @property (assign, nonatomic) NSUInteger finishedCount; 22 | @property (assign, nonatomic) NSTimeInterval startedTime; 23 | @property (copy, nonatomic) SDWebImagePrefetcherCompletionBlock completionBlock; 24 | @property (copy, nonatomic) SDWebImagePrefetcherProgressBlock progressBlock; 25 | 26 | @end 27 | 28 | @implementation SDWebImagePrefetcher 29 | 30 | + (SDWebImagePrefetcher *)sharedImagePrefetcher { 31 | static dispatch_once_t once; 32 | static id instance; 33 | dispatch_once(&once, ^{ 34 | instance = [self new]; 35 | }); 36 | return instance; 37 | } 38 | 39 | - (id)init { 40 | if ((self = [super init])) { 41 | _manager = [SDWebImageManager new]; 42 | _options = SDWebImageLowPriority; 43 | _prefetcherQueue = dispatch_get_main_queue(); 44 | self.maxConcurrentDownloads = 3; 45 | } 46 | return self; 47 | } 48 | 49 | - (void)setMaxConcurrentDownloads:(NSUInteger)maxConcurrentDownloads { 50 | self.manager.imageDownloader.maxConcurrentDownloads = maxConcurrentDownloads; 51 | } 52 | 53 | - (NSUInteger)maxConcurrentDownloads { 54 | return self.manager.imageDownloader.maxConcurrentDownloads; 55 | } 56 | 57 | - (void)startPrefetchingAtIndex:(NSUInteger)index { 58 | if (index >= self.prefetchURLs.count) return; 59 | self.requestedCount++; 60 | [self.manager downloadImageWithURL:self.prefetchURLs[index] options:self.options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 61 | if (!finished) return; 62 | self.finishedCount++; 63 | 64 | if (image) { 65 | if (self.progressBlock) { 66 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]); 67 | } 68 | NSLog(@"Prefetched %@ out of %@", @(self.finishedCount), @(self.prefetchURLs.count)); 69 | } 70 | else { 71 | if (self.progressBlock) { 72 | self.progressBlock(self.finishedCount,[self.prefetchURLs count]); 73 | } 74 | NSLog(@"Prefetched %@ out of %@ (Failed)", @(self.finishedCount), @(self.prefetchURLs.count)); 75 | 76 | // Add last failed 77 | self.skippedCount++; 78 | } 79 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didPrefetchURL:finishedCount:totalCount:)]) { 80 | [self.delegate imagePrefetcher:self 81 | didPrefetchURL:self.prefetchURLs[index] 82 | finishedCount:self.finishedCount 83 | totalCount:self.prefetchURLs.count 84 | ]; 85 | } 86 | if (self.prefetchURLs.count > self.requestedCount) { 87 | dispatch_async(self.prefetcherQueue, ^{ 88 | [self startPrefetchingAtIndex:self.requestedCount]; 89 | }); 90 | } 91 | else if (self.finishedCount == self.requestedCount) { 92 | [self reportStatus]; 93 | if (self.completionBlock) { 94 | self.completionBlock(self.finishedCount, self.skippedCount); 95 | self.completionBlock = nil; 96 | } 97 | self.progressBlock = nil; 98 | } 99 | }]; 100 | } 101 | 102 | - (void)reportStatus { 103 | NSUInteger total = [self.prefetchURLs count]; 104 | NSLog(@"Finished prefetching (%@ successful, %@ skipped, timeElasped %.2f)", @(total - self.skippedCount), @(self.skippedCount), CFAbsoluteTimeGetCurrent() - self.startedTime); 105 | if ([self.delegate respondsToSelector:@selector(imagePrefetcher:didFinishWithTotalCount:skippedCount:)]) { 106 | [self.delegate imagePrefetcher:self 107 | didFinishWithTotalCount:(total - self.skippedCount) 108 | skippedCount:self.skippedCount 109 | ]; 110 | } 111 | } 112 | 113 | - (void)prefetchURLs:(NSArray *)urls { 114 | [self prefetchURLs:urls progress:nil completed:nil]; 115 | } 116 | 117 | - (void)prefetchURLs:(NSArray *)urls progress:(SDWebImagePrefetcherProgressBlock)progressBlock completed:(SDWebImagePrefetcherCompletionBlock)completionBlock { 118 | [self cancelPrefetching]; // Prevent duplicate prefetch request 119 | self.startedTime = CFAbsoluteTimeGetCurrent(); 120 | self.prefetchURLs = urls; 121 | self.completionBlock = completionBlock; 122 | self.progressBlock = progressBlock; 123 | 124 | if(urls.count == 0){ 125 | if(completionBlock){ 126 | completionBlock(0,0); 127 | } 128 | }else{ 129 | // Starts prefetching from the very first image on the list with the max allowed concurrency 130 | NSUInteger listCount = self.prefetchURLs.count; 131 | for (NSUInteger i = 0; i < self.maxConcurrentDownloads && self.requestedCount < listCount; i++) { 132 | [self startPrefetchingAtIndex:i]; 133 | } 134 | } 135 | } 136 | 137 | - (void)cancelPrefetching { 138 | self.prefetchURLs = nil; 139 | self.skippedCount = 0; 140 | self.requestedCount = 0; 141 | self.finishedCount = 0; 142 | [self.manager cancelAll]; 143 | } 144 | 145 | @end 146 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/UIImage+GIF.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+GIF.h 3 | // LBGIFImage 4 | // 5 | // Created by Laurin Brandner on 06.01.12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (GIF) 12 | 13 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name; 14 | 15 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data; 16 | 17 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/UIImage+GIF.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+GIF.m 3 | // LBGIFImage 4 | // 5 | // Created by Laurin Brandner on 06.01.12. 6 | // Copyright (c) 2012 __MyCompanyName__. All rights reserved. 7 | // 8 | 9 | #import "UIImage+GIF.h" 10 | #import 11 | 12 | @implementation UIImage (GIF) 13 | 14 | + (UIImage *)sd_animatedGIFWithData:(NSData *)data { 15 | if (!data) { 16 | return nil; 17 | } 18 | 19 | CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)data, NULL); 20 | 21 | size_t count = CGImageSourceGetCount(source); 22 | 23 | UIImage *animatedImage; 24 | 25 | if (count <= 1) { 26 | animatedImage = [[UIImage alloc] initWithData:data]; 27 | } 28 | else { 29 | NSMutableArray *images = [NSMutableArray array]; 30 | 31 | NSTimeInterval duration = 0.0f; 32 | 33 | for (size_t i = 0; i < count; i++) { 34 | CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL); 35 | 36 | duration += [self sd_frameDurationAtIndex:i source:source]; 37 | 38 | [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]]; 39 | 40 | CGImageRelease(image); 41 | } 42 | 43 | if (!duration) { 44 | duration = (1.0f / 10.0f) * count; 45 | } 46 | 47 | animatedImage = [UIImage animatedImageWithImages:images duration:duration]; 48 | } 49 | 50 | CFRelease(source); 51 | 52 | return animatedImage; 53 | } 54 | 55 | + (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { 56 | float frameDuration = 0.1f; 57 | CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); 58 | NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; 59 | NSDictionary *gifProperties = frameProperties[(NSString *)kCGImagePropertyGIFDictionary]; 60 | 61 | NSNumber *delayTimeUnclampedProp = gifProperties[(NSString *)kCGImagePropertyGIFUnclampedDelayTime]; 62 | if (delayTimeUnclampedProp) { 63 | frameDuration = [delayTimeUnclampedProp floatValue]; 64 | } 65 | else { 66 | 67 | NSNumber *delayTimeProp = gifProperties[(NSString *)kCGImagePropertyGIFDelayTime]; 68 | if (delayTimeProp) { 69 | frameDuration = [delayTimeProp floatValue]; 70 | } 71 | } 72 | 73 | // Many annoying ads specify a 0 duration to make an image flash as quickly as possible. 74 | // We follow Firefox's behavior and use a duration of 100 ms for any frames that specify 75 | // a duration of <= 10 ms. See and 76 | // for more information. 77 | 78 | if (frameDuration < 0.011f) { 79 | frameDuration = 0.100f; 80 | } 81 | 82 | CFRelease(cfFrameProperties); 83 | return frameDuration; 84 | } 85 | 86 | + (UIImage *)sd_animatedGIFNamed:(NSString *)name { 87 | CGFloat scale = [UIScreen mainScreen].scale; 88 | 89 | if (scale > 1.0f) { 90 | NSString *retinaPath = [[NSBundle mainBundle] pathForResource:[name stringByAppendingString:@"@2x"] ofType:@"gif"]; 91 | 92 | NSData *data = [NSData dataWithContentsOfFile:retinaPath]; 93 | 94 | if (data) { 95 | return [UIImage sd_animatedGIFWithData:data]; 96 | } 97 | 98 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; 99 | 100 | data = [NSData dataWithContentsOfFile:path]; 101 | 102 | if (data) { 103 | return [UIImage sd_animatedGIFWithData:data]; 104 | } 105 | 106 | return [UIImage imageNamed:name]; 107 | } 108 | else { 109 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; 110 | 111 | NSData *data = [NSData dataWithContentsOfFile:path]; 112 | 113 | if (data) { 114 | return [UIImage sd_animatedGIFWithData:data]; 115 | } 116 | 117 | return [UIImage imageNamed:name]; 118 | } 119 | } 120 | 121 | - (UIImage *)sd_animatedImageByScalingAndCroppingToSize:(CGSize)size { 122 | if (CGSizeEqualToSize(self.size, size) || CGSizeEqualToSize(size, CGSizeZero)) { 123 | return self; 124 | } 125 | 126 | CGSize scaledSize = size; 127 | CGPoint thumbnailPoint = CGPointZero; 128 | 129 | CGFloat widthFactor = size.width / self.size.width; 130 | CGFloat heightFactor = size.height / self.size.height; 131 | CGFloat scaleFactor = (widthFactor > heightFactor) ? widthFactor : heightFactor; 132 | scaledSize.width = self.size.width * scaleFactor; 133 | scaledSize.height = self.size.height * scaleFactor; 134 | 135 | if (widthFactor > heightFactor) { 136 | thumbnailPoint.y = (size.height - scaledSize.height) * 0.5; 137 | } 138 | else if (widthFactor < heightFactor) { 139 | thumbnailPoint.x = (size.width - scaledSize.width) * 0.5; 140 | } 141 | 142 | NSMutableArray *scaledImages = [NSMutableArray array]; 143 | 144 | UIGraphicsBeginImageContextWithOptions(size, NO, 0.0); 145 | 146 | for (UIImage *image in self.images) { 147 | [image drawInRect:CGRectMake(thumbnailPoint.x, thumbnailPoint.y, scaledSize.width, scaledSize.height)]; 148 | UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); 149 | 150 | [scaledImages addObject:newImage]; 151 | } 152 | 153 | UIGraphicsEndImageContext(); 154 | 155 | return [UIImage animatedImageWithImages:scaledImages duration:self.duration]; 156 | } 157 | 158 | @end 159 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/UIImage+MultiFormat.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MultiFormat.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface UIImage (MultiFormat) 12 | 13 | + (UIImage *)sd_imageWithData:(NSData *)data; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/UIImage+MultiFormat.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+MultiFormat.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #import "UIImage+MultiFormat.h" 10 | #import "UIImage+GIF.h" 11 | #import "NSData+ImageContentType.h" 12 | #import 13 | 14 | #ifdef SD_WEBP 15 | #import "UIImage+WebP.h" 16 | #endif 17 | 18 | @implementation UIImage (MultiFormat) 19 | 20 | + (UIImage *)sd_imageWithData:(NSData *)data { 21 | UIImage *image; 22 | NSString *imageContentType = [NSData sd_contentTypeForImageData:data]; 23 | if ([imageContentType isEqualToString:@"image/gif"]) { 24 | image = [UIImage sd_animatedGIFWithData:data]; 25 | } 26 | #ifdef SD_WEBP 27 | else if ([imageContentType isEqualToString:@"image/webp"]) 28 | { 29 | image = [UIImage sd_imageWithWebPData:data]; 30 | } 31 | #endif 32 | else { 33 | image = [[UIImage alloc] initWithData:data]; 34 | UIImageOrientation orientation = [self sd_imageOrientationFromImageData:data]; 35 | if (orientation != UIImageOrientationUp) { 36 | image = [UIImage imageWithCGImage:image.CGImage 37 | scale:image.scale 38 | orientation:orientation]; 39 | } 40 | } 41 | 42 | 43 | return image; 44 | } 45 | 46 | 47 | +(UIImageOrientation)sd_imageOrientationFromImageData:(NSData *)imageData { 48 | UIImageOrientation result = UIImageOrientationUp; 49 | CGImageSourceRef imageSource = CGImageSourceCreateWithData((__bridge CFDataRef)imageData, NULL); 50 | if (imageSource) { 51 | CFDictionaryRef properties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, NULL); 52 | if (properties) { 53 | CFTypeRef val; 54 | int exifOrientation; 55 | val = CFDictionaryGetValue(properties, kCGImagePropertyOrientation); 56 | if (val) { 57 | CFNumberGetValue(val, kCFNumberIntType, &exifOrientation); 58 | result = [self sd_exifOrientationToiOSOrientation:exifOrientation]; 59 | } // else - if it's not set it remains at up 60 | CFRelease((CFTypeRef) properties); 61 | } else { 62 | //NSLog(@"NO PROPERTIES, FAIL"); 63 | } 64 | CFRelease(imageSource); 65 | } 66 | return result; 67 | } 68 | 69 | #pragma mark EXIF orientation tag converter 70 | // Convert an EXIF image orientation to an iOS one. 71 | // reference see here: http://sylvana.net/jpegcrop/exif_orientation.html 72 | + (UIImageOrientation) sd_exifOrientationToiOSOrientation:(int)exifOrientation { 73 | UIImageOrientation orientation = UIImageOrientationUp; 74 | switch (exifOrientation) { 75 | case 1: 76 | orientation = UIImageOrientationUp; 77 | break; 78 | 79 | case 3: 80 | orientation = UIImageOrientationDown; 81 | break; 82 | 83 | case 8: 84 | orientation = UIImageOrientationLeft; 85 | break; 86 | 87 | case 6: 88 | orientation = UIImageOrientationRight; 89 | break; 90 | 91 | case 2: 92 | orientation = UIImageOrientationUpMirrored; 93 | break; 94 | 95 | case 4: 96 | orientation = UIImageOrientationDownMirrored; 97 | break; 98 | 99 | case 5: 100 | orientation = UIImageOrientationLeftMirrored; 101 | break; 102 | 103 | case 7: 104 | orientation = UIImageOrientationRightMirrored; 105 | break; 106 | default: 107 | break; 108 | } 109 | return orientation; 110 | } 111 | 112 | 113 | 114 | @end 115 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/UIImage+WebP.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+WebP.h 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #ifdef SD_WEBP 10 | 11 | #import 12 | 13 | // Fix for issue #416 Undefined symbols for architecture armv7 since WebP introduction when deploying to device 14 | void WebPInitPremultiplyNEON(void); 15 | 16 | void WebPInitUpsamplersNEON(void); 17 | 18 | void VP8DspInitNEON(void); 19 | 20 | @interface UIImage (WebP) 21 | 22 | + (UIImage *)sd_imageWithWebPData:(NSData *)data; 23 | 24 | @end 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/UIImage+WebP.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIImage+WebP.m 3 | // SDWebImage 4 | // 5 | // Created by Olivier Poitrey on 07/06/13. 6 | // Copyright (c) 2013 Dailymotion. All rights reserved. 7 | // 8 | 9 | #ifdef SD_WEBP 10 | #import "UIImage+WebP.h" 11 | #import "webp/decode.h" 12 | 13 | // Callback for CGDataProviderRelease 14 | static void FreeImageData(void *info, const void *data, size_t size) 15 | { 16 | free((void *)data); 17 | } 18 | 19 | @implementation UIImage (WebP) 20 | 21 | + (UIImage *)sd_imageWithWebPData:(NSData *)data { 22 | WebPDecoderConfig config; 23 | if (!WebPInitDecoderConfig(&config)) { 24 | return nil; 25 | } 26 | 27 | if (WebPGetFeatures(data.bytes, data.length, &config.input) != VP8_STATUS_OK) { 28 | return nil; 29 | } 30 | 31 | config.output.colorspace = config.input.has_alpha ? MODE_rgbA : MODE_RGB; 32 | config.options.use_threads = 1; 33 | 34 | // Decode the WebP image data into a RGBA value array. 35 | if (WebPDecode(data.bytes, data.length, &config) != VP8_STATUS_OK) { 36 | return nil; 37 | } 38 | 39 | int width = config.input.width; 40 | int height = config.input.height; 41 | if (config.options.use_scaling) { 42 | width = config.options.scaled_width; 43 | height = config.options.scaled_height; 44 | } 45 | 46 | // Construct a UIImage from the decoded RGBA value array. 47 | CGDataProviderRef provider = 48 | CGDataProviderCreateWithData(NULL, config.output.u.RGBA.rgba, config.output.u.RGBA.size, FreeImageData); 49 | CGColorSpaceRef colorSpaceRef = CGColorSpaceCreateDeviceRGB(); 50 | CGBitmapInfo bitmapInfo = config.input.has_alpha ? kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast : 0; 51 | size_t components = config.input.has_alpha ? 4 : 3; 52 | CGColorRenderingIntent renderingIntent = kCGRenderingIntentDefault; 53 | CGImageRef imageRef = CGImageCreate(width, height, 8, components * 8, components * width, colorSpaceRef, bitmapInfo, provider, NULL, NO, renderingIntent); 54 | 55 | CGColorSpaceRelease(colorSpaceRef); 56 | CGDataProviderRelease(provider); 57 | 58 | UIImage *image = [[UIImage alloc] initWithCGImage:imageRef]; 59 | CGImageRelease(imageRef); 60 | 61 | return image; 62 | } 63 | 64 | @end 65 | 66 | #if !COCOAPODS 67 | // Functions to resolve some undefined symbols when using WebP and force_load flag 68 | void WebPInitPremultiplyNEON(void) {} 69 | void WebPInitUpsamplersNEON(void) {} 70 | void VP8DspInitNEON(void) {} 71 | #endif 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/UIImageView+HighlightedWebCache.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageCompat.h" 11 | #import "SDWebImageManager.h" 12 | 13 | /** 14 | * Integrates SDWebImage async downloading and caching of remote images with UIImageView for highlighted state. 15 | */ 16 | @interface UIImageView (HighlightedWebCache) 17 | 18 | /** 19 | * Set the imageView `highlightedImage` with an `url`. 20 | * 21 | * The download is asynchronous and cached. 22 | * 23 | * @param url The url for the image. 24 | */ 25 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url; 26 | 27 | /** 28 | * Set the imageView `highlightedImage` with an `url` and custom options. 29 | * 30 | * The download is asynchronous and cached. 31 | * 32 | * @param url The url for the image. 33 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 34 | */ 35 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options; 36 | 37 | /** 38 | * Set the imageView `highlightedImage` with an `url`. 39 | * 40 | * The download is asynchronous and cached. 41 | * 42 | * @param url The url for the image. 43 | * @param completedBlock A block called when operation has been completed. This block has no return value 44 | * and takes the requested UIImage as first parameter. In case of error the image parameter 45 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 46 | * indicating if the image was retrived from the local cache or from the network. 47 | * The fourth parameter is the original image url. 48 | */ 49 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock; 50 | 51 | /** 52 | * Set the imageView `highlightedImage` with an `url` and custom options. 53 | * 54 | * The download is asynchronous and cached. 55 | * 56 | * @param url The url for the image. 57 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 58 | * @param completedBlock A block called when operation has been completed. This block has no return value 59 | * and takes the requested UIImage as first parameter. In case of error the image parameter 60 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 61 | * indicating if the image was retrived from the local cache or from the network. 62 | * The fourth parameter is the original image url. 63 | */ 64 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock; 65 | 66 | /** 67 | * Set the imageView `highlightedImage` with an `url` and custom options. 68 | * 69 | * The download is asynchronous and cached. 70 | * 71 | * @param url The url for the image. 72 | * @param options The options to use when downloading the image. @see SDWebImageOptions for the possible values. 73 | * @param progressBlock A block called while image is downloading 74 | * @param completedBlock A block called when operation has been completed. This block has no return value 75 | * and takes the requested UIImage as first parameter. In case of error the image parameter 76 | * is nil and the second parameter may contain an NSError. The third parameter is a Boolean 77 | * indicating if the image was retrived from the local cache or from the network. 78 | * The fourth parameter is the original image url. 79 | */ 80 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock; 81 | 82 | /** 83 | * Cancel the current download 84 | */ 85 | - (void)sd_cancelCurrentHighlightedImageLoad; 86 | 87 | @end 88 | 89 | 90 | @interface UIImageView (HighlightedWebCacheDeprecated) 91 | 92 | - (void)setHighlightedImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:`"); 93 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:`"); 94 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:completed:`"); 95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`"); 96 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`"); 97 | 98 | - (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`"); 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/UIImageView+HighlightedWebCache.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIImageView+HighlightedWebCache.h" 10 | #import "UIView+WebCacheOperation.h" 11 | 12 | #define UIImageViewHighlightedWebCacheOperationKey @"highlightedImage" 13 | 14 | @implementation UIImageView (HighlightedWebCache) 15 | 16 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url { 17 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 18 | } 19 | 20 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { 21 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 22 | } 23 | 24 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletionBlock)completedBlock { 25 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:completedBlock]; 26 | } 27 | 28 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { 29 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:completedBlock]; 30 | } 31 | 32 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { 33 | [self sd_cancelCurrentHighlightedImageLoad]; 34 | 35 | if (url) { 36 | __weak __typeof(self)wself = self; 37 | id operation = [SDWebImageManager.sharedManager downloadImageWithURL:url options:options progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 38 | if (!wself) return; 39 | dispatch_main_sync_safe (^ 40 | { 41 | if (!wself) return; 42 | if (image) { 43 | wself.highlightedImage = image; 44 | [wself setNeedsLayout]; 45 | } 46 | if (completedBlock && finished) { 47 | completedBlock(image, error, cacheType, url); 48 | } 49 | }); 50 | }]; 51 | [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; 52 | } else { 53 | dispatch_main_async_safe(^{ 54 | NSError *error = [NSError errorWithDomain:SDWebImageErrorDomain code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; 55 | if (completedBlock) { 56 | completedBlock(nil, error, SDImageCacheTypeNone, url); 57 | } 58 | }); 59 | } 60 | } 61 | 62 | - (void)sd_cancelCurrentHighlightedImageLoad { 63 | [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey]; 64 | } 65 | 66 | @end 67 | 68 | 69 | @implementation UIImageView (HighlightedWebCacheDeprecated) 70 | 71 | - (void)setHighlightedImageWithURL:(NSURL *)url { 72 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:nil]; 73 | } 74 | 75 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options { 76 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:nil]; 77 | } 78 | 79 | - (void)setHighlightedImageWithURL:(NSURL *)url completed:(SDWebImageCompletedBlock)completedBlock { 80 | [self sd_setHighlightedImageWithURL:url options:0 progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 81 | if (completedBlock) { 82 | completedBlock(image, error, cacheType); 83 | } 84 | }]; 85 | } 86 | 87 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 88 | [self sd_setHighlightedImageWithURL:url options:options progress:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 89 | if (completedBlock) { 90 | completedBlock(image, error, cacheType); 91 | } 92 | }]; 93 | } 94 | 95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { 96 | [self sd_setHighlightedImageWithURL:url options:0 progress:progressBlock completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) { 97 | if (completedBlock) { 98 | completedBlock(image, error, cacheType); 99 | } 100 | }]; 101 | } 102 | 103 | - (void)cancelCurrentHighlightedImageLoad { 104 | [self sd_cancelCurrentHighlightedImageLoad]; 105 | } 106 | 107 | @end 108 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/UIView+WebCacheOperation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import 10 | #import "SDWebImageManager.h" 11 | 12 | @interface UIView (WebCacheOperation) 13 | 14 | /** 15 | * Set the image load operation (storage in a UIView based dictionary) 16 | * 17 | * @param operation the operation 18 | * @param key key for storing the operation 19 | */ 20 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key; 21 | 22 | /** 23 | * Cancel all operations for the current UIView and key 24 | * 25 | * @param key key for identifying the operations 26 | */ 27 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key; 28 | 29 | /** 30 | * Just remove the operations corresponding to the current UIView and key without cancelling them 31 | * 32 | * @param key key for identifying the operations 33 | */ 34 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/SDWebImage/UIView+WebCacheOperation.m: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of the SDWebImage package. 3 | * (c) Olivier Poitrey 4 | * 5 | * For the full copyright and license information, please view the LICENSE 6 | * file that was distributed with this source code. 7 | */ 8 | 9 | #import "UIView+WebCacheOperation.h" 10 | #import "objc/runtime.h" 11 | 12 | static char loadOperationKey; 13 | 14 | @implementation UIView (WebCacheOperation) 15 | 16 | - (NSMutableDictionary *)operationDictionary { 17 | NSMutableDictionary *operations = objc_getAssociatedObject(self, &loadOperationKey); 18 | if (operations) { 19 | return operations; 20 | } 21 | operations = [NSMutableDictionary dictionary]; 22 | objc_setAssociatedObject(self, &loadOperationKey, operations, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 23 | return operations; 24 | } 25 | 26 | - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key { 27 | [self sd_cancelImageLoadOperationWithKey:key]; 28 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 29 | [operationDictionary setObject:operation forKey:key]; 30 | } 31 | 32 | - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key { 33 | // Cancel in progress downloader from queue 34 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 35 | id operations = [operationDictionary objectForKey:key]; 36 | if (operations) { 37 | if ([operations isKindOfClass:[NSArray class]]) { 38 | for (id operation in operations) { 39 | if (operation) { 40 | [operation cancel]; 41 | } 42 | } 43 | } else if ([operations conformsToProtocol:@protocol(SDWebImageOperation)]){ 44 | [(id) operations cancel]; 45 | } 46 | [operationDictionary removeObjectForKey:key]; 47 | } 48 | } 49 | 50 | - (void)sd_removeImageLoadOperationWithKey:(NSString *)key { 51 | NSMutableDictionary *operationDictionary = [self operationDictionary]; 52 | [operationDictionary removeObjectForKey:key]; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIAlertView-Blocks/.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIAlertView-Blocks/UIAlertView+Blocks.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIAlertView+Blocks.h 3 | // UIAlertViewBlocks 4 | // 5 | // Created by Ryan Maxwell on 29/08/13. 6 | // 7 | // The MIT License (MIT) 8 | // 9 | // Copyright (c) 2013 Ryan Maxwell 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 12 | // this software and associated documentation files (the "Software"), to deal in 13 | // the Software without restriction, including without limitation the rights to 14 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 15 | // the Software, and to permit persons to whom the Software is furnished to do so, 16 | // subject to the following conditions: 17 | // 18 | // The above copyright notice and this permission notice shall be included in all 19 | // copies or substantial portions of the Software. 20 | // 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 23 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 24 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 25 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 26 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 27 | // 28 | 29 | #import 30 | 31 | typedef void (^UIAlertViewBlock) (UIAlertView *alertView); 32 | typedef void (^UIAlertViewCompletionBlock) (UIAlertView *alertView, NSInteger buttonIndex); 33 | 34 | @interface UIAlertView (Blocks) 35 | 36 | + (instancetype)showWithTitle:(NSString *)title 37 | message:(NSString *)message 38 | style:(UIAlertViewStyle)style 39 | cancelButtonTitle:(NSString *)cancelButtonTitle 40 | otherButtonTitles:(NSArray *)otherButtonTitles 41 | tapBlock:(UIAlertViewCompletionBlock)tapBlock; 42 | 43 | + (instancetype)showWithTitle:(NSString *)title 44 | message:(NSString *)message 45 | cancelButtonTitle:(NSString *)cancelButtonTitle 46 | otherButtonTitles:(NSArray *)otherButtonTitles 47 | tapBlock:(UIAlertViewCompletionBlock)tapBlock; 48 | 49 | @property (copy, nonatomic) UIAlertViewCompletionBlock tapBlock; 50 | @property (copy, nonatomic) UIAlertViewCompletionBlock willDismissBlock; 51 | @property (copy, nonatomic) UIAlertViewCompletionBlock didDismissBlock; 52 | 53 | @property (copy, nonatomic) UIAlertViewBlock willPresentBlock; 54 | @property (copy, nonatomic) UIAlertViewBlock didPresentBlock; 55 | @property (copy, nonatomic) UIAlertViewBlock cancelBlock; 56 | 57 | @property (copy, nonatomic) BOOL(^shouldEnableFirstOtherButtonBlock)(UIAlertView *alertView); 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIImageViewAligned/UIImageViewAligned.h: -------------------------------------------------------------------------------- 1 | // 2 | // UIImageViewAligned.h 3 | // awards 4 | // 5 | // Created by Andrei Stanescu on 7/29/13. 6 | // 7 | 8 | #import 9 | 10 | typedef enum 11 | { 12 | UIImageViewAlignmentMaskCenter = 0, 13 | 14 | UIImageViewAlignmentMaskLeft = 1, 15 | UIImageViewAlignmentMaskRight = 2, 16 | UIImageViewAlignmentMaskTop = 4, 17 | UIImageViewAlignmentMaskBottom = 8, 18 | 19 | UIImageViewAlignmentMaskBottomLeft = UIImageViewAlignmentMaskBottom | UIImageViewAlignmentMaskLeft, 20 | UIImageViewAlignmentMaskBottomRight = UIImageViewAlignmentMaskBottom | UIImageViewAlignmentMaskRight, 21 | UIImageViewAlignmentMaskTopLeft = UIImageViewAlignmentMaskTop | UIImageViewAlignmentMaskLeft, 22 | UIImageViewAlignmentMaskTopRight = UIImageViewAlignmentMaskTop | UIImageViewAlignmentMaskRight, 23 | 24 | }UIImageViewAlignmentMask; 25 | 26 | typedef UIImageViewAlignmentMask UIImageViewAignmentMask __attribute__((deprecated("Use UIImageViewAlignmentMask. Use of UIImageViewAignmentMask (misspelled) is deprecated."))); 27 | 28 | 29 | 30 | @interface UIImageViewAligned : UIImageView 31 | 32 | // This property holds the current alignment 33 | @property (nonatomic) UIImageViewAlignmentMask alignment; 34 | 35 | // Properties needed for Interface Builder quick setup 36 | @property (nonatomic) BOOL alignLeft; 37 | @property (nonatomic) BOOL alignRight; 38 | @property (nonatomic) BOOL alignTop; 39 | @property (nonatomic) BOOL alignBottom; 40 | 41 | // Make the UIImageView scale only up or down 42 | // This are used only if the content mode is Scaled 43 | @property (nonatomic) BOOL enableScaleUp; 44 | @property (nonatomic) BOOL enableScaleDown; 45 | 46 | // Just in case you need access to the inner image view 47 | @property (nonatomic, readonly) UIImageView* realImageView; 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | 29 | #import 30 | 31 | /** 32 | `AFNetworkActivityIndicatorManager` manages the state of the network activity indicator in the status bar. When enabled, it will listen for notifications indicating that a network request operation has started or finished, and start or stop animating the indicator accordingly. The number of active requests is incremented and decremented much like a stack or a semaphore, and the activity indicator will animate so long as that number is greater than zero. 33 | 34 | You should enable the shared instance of `AFNetworkActivityIndicatorManager` when your application finishes launching. In `AppDelegate application:didFinishLaunchingWithOptions:` you can do so with the following code: 35 | 36 | [[AFNetworkActivityIndicatorManager sharedManager] setEnabled:YES]; 37 | 38 | By setting `enabled` to `YES` for `sharedManager`, the network activity indicator will show and hide automatically as requests start and finish. You should not ever need to call `incrementActivityCount` or `decrementActivityCount` yourself. 39 | 40 | See the Apple Human Interface Guidelines section about the Network Activity Indicator for more information: 41 | http://developer.apple.com/library/iOS/#documentation/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html#//apple_ref/doc/uid/TP40006556-CH13-SW44 42 | */ 43 | @interface AFNetworkActivityIndicatorManager : NSObject 44 | 45 | /** 46 | A Boolean value indicating whether the manager is enabled. 47 | 48 | If YES, the manager will change status bar network activity indicator according to network operation notifications it receives. The default value is NO. 49 | */ 50 | @property (nonatomic, assign, getter = isEnabled) BOOL enabled; 51 | 52 | /** 53 | A Boolean value indicating whether the network activity indicator is currently displayed in the status bar. 54 | */ 55 | @property (readonly, nonatomic, assign) BOOL isNetworkActivityIndicatorVisible; 56 | 57 | /** 58 | Returns the shared network activity indicator manager object for the system. 59 | 60 | @return The systemwide network activity indicator manager. 61 | */ 62 | + (instancetype)sharedManager; 63 | 64 | /** 65 | Increments the number of active network requests. If this number was zero before incrementing, this will start animating the status bar network activity indicator. 66 | */ 67 | - (void)incrementActivityCount; 68 | 69 | /** 70 | Decrements the number of active network requests. If this number becomes zero after decrementing, this will stop animating the status bar network activity indicator. 71 | */ 72 | - (void)decrementActivityCount; 73 | 74 | @end 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m: -------------------------------------------------------------------------------- 1 | // AFNetworkActivityIndicatorManager.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "AFNetworkActivityIndicatorManager.h" 24 | 25 | #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) 26 | 27 | #import "AFHTTPRequestOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | static NSTimeInterval const kAFNetworkActivityIndicatorInvisibilityDelay = 0.17; 34 | 35 | static NSURLRequest * AFNetworkRequestFromNotification(NSNotification *notification) { 36 | if ([[notification object] isKindOfClass:[AFURLConnectionOperation class]]) { 37 | return [(AFURLConnectionOperation *)[notification object] request]; 38 | } 39 | 40 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 41 | if ([[notification object] respondsToSelector:@selector(originalRequest)]) { 42 | return [(NSURLSessionTask *)[notification object] originalRequest]; 43 | } 44 | #endif 45 | 46 | return nil; 47 | } 48 | 49 | @interface AFNetworkActivityIndicatorManager () 50 | @property (readwrite, nonatomic, assign) NSInteger activityCount; 51 | @property (readwrite, nonatomic, strong) NSTimer *activityIndicatorVisibilityTimer; 52 | @property (readonly, nonatomic, getter = isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible; 53 | 54 | - (void)updateNetworkActivityIndicatorVisibility; 55 | - (void)updateNetworkActivityIndicatorVisibilityDelayed; 56 | @end 57 | 58 | @implementation AFNetworkActivityIndicatorManager 59 | @dynamic networkActivityIndicatorVisible; 60 | 61 | + (instancetype)sharedManager { 62 | static AFNetworkActivityIndicatorManager *_sharedManager = nil; 63 | static dispatch_once_t oncePredicate; 64 | dispatch_once(&oncePredicate, ^{ 65 | _sharedManager = [[self alloc] init]; 66 | }); 67 | 68 | return _sharedManager; 69 | } 70 | 71 | + (NSSet *)keyPathsForValuesAffectingIsNetworkActivityIndicatorVisible { 72 | return [NSSet setWithObject:@"activityCount"]; 73 | } 74 | 75 | - (id)init { 76 | self = [super init]; 77 | if (!self) { 78 | return nil; 79 | } 80 | 81 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingOperationDidStartNotification object:nil]; 82 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingOperationDidFinishNotification object:nil]; 83 | 84 | #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 70000 85 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidStart:) name:AFNetworkingTaskDidResumeNotification object:nil]; 86 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidSuspendNotification object:nil]; 87 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(networkRequestDidFinish:) name:AFNetworkingTaskDidCompleteNotification object:nil]; 88 | #endif 89 | 90 | return self; 91 | } 92 | 93 | - (void)dealloc { 94 | [[NSNotificationCenter defaultCenter] removeObserver:self]; 95 | 96 | [_activityIndicatorVisibilityTimer invalidate]; 97 | } 98 | 99 | - (void)updateNetworkActivityIndicatorVisibilityDelayed { 100 | if (self.enabled) { 101 | // Delay hiding of activity indicator for a short interval, to avoid flickering 102 | if (![self isNetworkActivityIndicatorVisible]) { 103 | [self.activityIndicatorVisibilityTimer invalidate]; 104 | self.activityIndicatorVisibilityTimer = [NSTimer timerWithTimeInterval:kAFNetworkActivityIndicatorInvisibilityDelay target:self selector:@selector(updateNetworkActivityIndicatorVisibility) userInfo:nil repeats:NO]; 105 | [[NSRunLoop mainRunLoop] addTimer:self.activityIndicatorVisibilityTimer forMode:NSRunLoopCommonModes]; 106 | } else { 107 | [self performSelectorOnMainThread:@selector(updateNetworkActivityIndicatorVisibility) withObject:nil waitUntilDone:NO modes:@[NSRunLoopCommonModes]]; 108 | } 109 | } 110 | } 111 | 112 | - (BOOL)isNetworkActivityIndicatorVisible { 113 | return self.activityCount > 0; 114 | } 115 | 116 | - (void)updateNetworkActivityIndicatorVisibility { 117 | #if !defined(AF_APP_EXTENSIONS) 118 | [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:[self isNetworkActivityIndicatorVisible]]; 119 | #endif 120 | } 121 | 122 | - (void)setActivityCount:(NSInteger)activityCount { 123 | @synchronized(self) { 124 | _activityCount = activityCount; 125 | } 126 | 127 | dispatch_async(dispatch_get_main_queue(), ^{ 128 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 129 | }); 130 | } 131 | 132 | - (void)incrementActivityCount { 133 | [self willChangeValueForKey:@"activityCount"]; 134 | @synchronized(self) { 135 | _activityCount++; 136 | } 137 | [self didChangeValueForKey:@"activityCount"]; 138 | 139 | dispatch_async(dispatch_get_main_queue(), ^{ 140 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 141 | }); 142 | } 143 | 144 | - (void)decrementActivityCount { 145 | [self willChangeValueForKey:@"activityCount"]; 146 | @synchronized(self) { 147 | #pragma clang diagnostic push 148 | #pragma clang diagnostic ignored "-Wgnu" 149 | _activityCount = MAX(_activityCount - 1, 0); 150 | #pragma clang diagnostic pop 151 | } 152 | [self didChangeValueForKey:@"activityCount"]; 153 | 154 | dispatch_async(dispatch_get_main_queue(), ^{ 155 | [self updateNetworkActivityIndicatorVisibilityDelayed]; 156 | }); 157 | } 158 | 159 | - (void)networkRequestDidStart:(NSNotification *)notification { 160 | if ([AFNetworkRequestFromNotification(notification) URL]) { 161 | [self incrementActivityCount]; 162 | } 163 | } 164 | 165 | - (void)networkRequestDidFinish:(NSNotification *)notification { 166 | if ([AFNetworkRequestFromNotification(notification) URL]) { 167 | [self decrementActivityCount]; 168 | } 169 | } 170 | 171 | @end 172 | 173 | #endif 174 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | 29 | #import 30 | 31 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIActivityIndicatorView` class. The methods in this category provide support for automatically starting and stopping animation depending on the loading state of a request operation or session task. 35 | */ 36 | @interface UIActivityIndicatorView (AFNetworking) 37 | 38 | ///---------------------------------- 39 | /// @name Animating for Session Tasks 40 | ///---------------------------------- 41 | 42 | /** 43 | Binds the animating state to the state of the specified task. 44 | 45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 46 | */ 47 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 48 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task; 49 | #endif 50 | 51 | ///--------------------------------------- 52 | /// @name Animating for Request Operations 53 | ///--------------------------------------- 54 | 55 | /** 56 | Binds the animating state to the execution state of the specified operation. 57 | 58 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. 59 | */ 60 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation; 61 | 62 | @end 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/UIActivityIndicatorView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIActivityIndicatorView+AFNetworking.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "UIActivityIndicatorView+AFNetworking.h" 24 | 25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 26 | 27 | #import "AFHTTPRequestOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | @implementation UIActivityIndicatorView (AFNetworking) 34 | 35 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 36 | - (void)setAnimatingWithStateOfTask:(NSURLSessionTask *)task { 37 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 38 | 39 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 40 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 41 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 42 | 43 | if (task) { 44 | if (task.state != NSURLSessionTaskStateCompleted) { 45 | if (task.state == NSURLSessionTaskStateRunning) { 46 | [self startAnimating]; 47 | } else { 48 | [self stopAnimating]; 49 | } 50 | 51 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingTaskDidResumeNotification object:task]; 52 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidCompleteNotification object:task]; 53 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingTaskDidSuspendNotification object:task]; 54 | } 55 | } 56 | } 57 | #endif 58 | 59 | #pragma mark - 60 | 61 | - (void)setAnimatingWithStateOfOperation:(AFURLConnectionOperation *)operation { 62 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 63 | 64 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 65 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 66 | 67 | if (operation) { 68 | if (![operation isFinished]) { 69 | if ([operation isExecuting]) { 70 | [self startAnimating]; 71 | } else { 72 | [self stopAnimating]; 73 | } 74 | 75 | [notificationCenter addObserver:self selector:@selector(af_startAnimating) name:AFNetworkingOperationDidStartNotification object:operation]; 76 | [notificationCenter addObserver:self selector:@selector(af_stopAnimating) name:AFNetworkingOperationDidFinishNotification object:operation]; 77 | } 78 | } 79 | } 80 | 81 | #pragma mark - 82 | 83 | - (void)af_startAnimating { 84 | dispatch_async(dispatch_get_main_queue(), ^{ 85 | [self startAnimating]; 86 | }); 87 | } 88 | 89 | - (void)af_stopAnimating { 90 | dispatch_async(dispatch_get_main_queue(), ^{ 91 | [self stopAnimating]; 92 | }); 93 | } 94 | 95 | @end 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/UIAlertView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIAlertView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) 28 | 29 | #import 30 | 31 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIAlertView` class. The methods in this category provide support for automatically showing an alert if a session task or request operation finishes with an error. Alert title and message are filled from the corresponding `localizedDescription` & `localizedRecoverySuggestion` or `localizedFailureReason` of the error. 35 | */ 36 | @interface UIAlertView (AFNetworking) 37 | 38 | ///------------------------------------- 39 | /// @name Showing Alert for Session Task 40 | ///------------------------------------- 41 | 42 | /** 43 | Shows an alert view with the error of the specified session task, if any. 44 | 45 | @param task The session task. 46 | @param delegate The alert view delegate. 47 | */ 48 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 49 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 50 | delegate:(id)delegate; 51 | #endif 52 | 53 | /** 54 | Shows an alert view with the error of the specified session task, if any, with a custom cancel button title and other button titles. 55 | 56 | @param task The session task. 57 | @param delegate The alert view delegate. 58 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. 59 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. 60 | */ 61 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 62 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 63 | delegate:(id)delegate 64 | cancelButtonTitle:(NSString *)cancelButtonTitle 65 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; 66 | #endif 67 | 68 | ///------------------------------------------ 69 | /// @name Showing Alert for Request Operation 70 | ///------------------------------------------ 71 | 72 | /** 73 | Shows an alert view with the error of the specified request operation, if any. 74 | 75 | @param operation The request operation. 76 | @param delegate The alert view delegate. 77 | */ 78 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 79 | delegate:(id)delegate; 80 | 81 | /** 82 | Shows an alert view with the error of the specified request operation, if any, with a custom cancel button title and other button titles. 83 | 84 | @param operation The request operation. 85 | @param delegate The alert view delegate. 86 | @param cancelButtonTitle The title of the cancel button or nil if there is no cancel button. Using this argument is equivalent to setting the cancel button index to the value returned by invoking addButtonWithTitle: specifying this title. 87 | @param otherButtonTitles The title of another button. Using this argument is equivalent to invoking addButtonWithTitle: with this title to add more buttons. Too many buttons can cause the alert view to scroll. For guidelines on the best ways to use an alert in an app, see "Temporary Views". Titles of additional buttons to add to the receiver, terminated with `nil`. 88 | */ 89 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 90 | delegate:(id)delegate 91 | cancelButtonTitle:(NSString *)cancelButtonTitle 92 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION; 93 | 94 | @end 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/UIAlertView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIAlertView+AFNetworking.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "UIAlertView+AFNetworking.h" 24 | 25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && !defined(AF_APP_EXTENSIONS) 26 | 27 | #import "AFURLConnectionOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | static void AFGetAlertViewTitleAndMessageFromError(NSError *error, NSString * __autoreleasing *title, NSString * __autoreleasing *message) { 34 | if (error.localizedDescription && (error.localizedRecoverySuggestion || error.localizedFailureReason)) { 35 | *title = error.localizedDescription; 36 | 37 | if (error.localizedRecoverySuggestion) { 38 | *message = error.localizedRecoverySuggestion; 39 | } else { 40 | *message = error.localizedFailureReason; 41 | } 42 | } else if (error.localizedDescription) { 43 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); 44 | *message = error.localizedDescription; 45 | } else { 46 | *title = NSLocalizedStringFromTable(@"Error", @"AFNetworking", @"Fallback Error Description"); 47 | *message = [NSString stringWithFormat:NSLocalizedStringFromTable(@"%@ Error: %ld", @"AFNetworking", @"Fallback Error Failure Reason Format"), error.domain, (long)error.code]; 48 | } 49 | } 50 | 51 | @implementation UIAlertView (AFNetworking) 52 | 53 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 54 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 55 | delegate:(id)delegate 56 | { 57 | [self showAlertViewForTaskWithErrorOnCompletion:task delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; 58 | } 59 | 60 | + (void)showAlertViewForTaskWithErrorOnCompletion:(NSURLSessionTask *)task 61 | delegate:(id)delegate 62 | cancelButtonTitle:(NSString *)cancelButtonTitle 63 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION 64 | { 65 | va_list otherTitleList; 66 | va_start(otherTitleList, otherButtonTitles); 67 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; 68 | for(NSString *otherTitle = otherButtonTitles; otherTitle != nil; otherTitle = va_arg(otherTitleList, NSString *)){ 69 | [alertView addButtonWithTitle:otherTitle]; 70 | } 71 | va_end(otherTitleList); 72 | __block id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingTaskDidCompleteNotification object:task queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { 73 | 74 | NSError *error = notification.userInfo[AFNetworkingTaskDidCompleteErrorKey]; 75 | if (error) { 76 | NSString *title, *message; 77 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message); 78 | 79 | [alertView setTitle:title]; 80 | [alertView setMessage:message]; 81 | [alertView show]; 82 | } 83 | 84 | [[NSNotificationCenter defaultCenter] removeObserver:observer name:AFNetworkingTaskDidCompleteNotification object:notification.object]; 85 | }]; 86 | } 87 | #endif 88 | 89 | #pragma mark - 90 | 91 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 92 | delegate:(id)delegate 93 | { 94 | [self showAlertViewForRequestOperationWithErrorOnCompletion:operation delegate:delegate cancelButtonTitle:NSLocalizedStringFromTable(@"Dismiss", @"AFNetworking", @"UIAlertView Cancel Button Title") otherButtonTitles:nil, nil]; 95 | } 96 | 97 | + (void)showAlertViewForRequestOperationWithErrorOnCompletion:(AFURLConnectionOperation *)operation 98 | delegate:(id)delegate 99 | cancelButtonTitle:(NSString *)cancelButtonTitle 100 | otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION 101 | { 102 | va_list otherTitleList; 103 | va_start(otherTitleList, otherButtonTitles); 104 | UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:nil delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:nil, nil]; 105 | for(NSString *otherTitle = otherButtonTitles; otherTitle != nil; otherTitle = va_arg(otherTitleList, NSString *)){ 106 | [alertView addButtonWithTitle:otherTitle]; 107 | } 108 | va_end(otherTitleList); 109 | __block id observer = [[NSNotificationCenter defaultCenter] addObserverForName:AFNetworkingOperationDidFinishNotification object:operation queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { 110 | 111 | if (notification.object && [notification.object isKindOfClass:[AFURLConnectionOperation class]]) { 112 | NSError *error = [(AFURLConnectionOperation *)notification.object error]; 113 | if (error) { 114 | NSString *title, *message; 115 | AFGetAlertViewTitleAndMessageFromError(error, &title, &message); 116 | 117 | [alertView setTitle:title]; 118 | [alertView setMessage:message]; 119 | [alertView show]; 120 | } 121 | } 122 | 123 | [[NSNotificationCenter defaultCenter] removeObserver:observer name:AFNetworkingOperationDidFinishNotification object:notification.object]; 124 | }]; 125 | } 126 | 127 | @end 128 | 129 | #endif 130 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/UIKit+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIKit+AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #ifndef _UIKIT_AFNETWORKING_ 26 | #define _UIKIT_AFNETWORKING_ 27 | 28 | #import "AFNetworkActivityIndicatorManager.h" 29 | 30 | #import "UIActivityIndicatorView+AFNetworking.h" 31 | #import "UIAlertView+AFNetworking.h" 32 | #import "UIButton+AFNetworking.h" 33 | #import "UIImageView+AFNetworking.h" 34 | #import "UIKit+AFNetworking.h" 35 | #import "UIProgressView+AFNetworking.h" 36 | #import "UIRefreshControl+AFNetworking.h" 37 | #import "UIWebView+AFNetworking.h" 38 | #endif /* _UIKIT_AFNETWORKING_ */ 39 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/UIProgressView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIProgressView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | 29 | #import 30 | 31 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIProgressView` class. The methods in this category provide support for binding the progress to the upload and download progress of a session task or request operation. 35 | */ 36 | @interface UIProgressView (AFNetworking) 37 | 38 | ///------------------------------------ 39 | /// @name Setting Session Task Progress 40 | ///------------------------------------ 41 | 42 | /** 43 | Binds the progress to the upload progress of the specified session task. 44 | 45 | @param task The session task. 46 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 47 | */ 48 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 49 | - (void)setProgressWithUploadProgressOfTask:(NSURLSessionUploadTask *)task 50 | animated:(BOOL)animated; 51 | #endif 52 | 53 | /** 54 | Binds the progress to the download progress of the specified session task. 55 | 56 | @param task The session task. 57 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 58 | */ 59 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 60 | - (void)setProgressWithDownloadProgressOfTask:(NSURLSessionDownloadTask *)task 61 | animated:(BOOL)animated; 62 | #endif 63 | 64 | ///------------------------------------ 65 | /// @name Setting Session Task Progress 66 | ///------------------------------------ 67 | 68 | /** 69 | Binds the progress to the upload progress of the specified request operation. 70 | 71 | @param operation The request operation. 72 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 73 | */ 74 | - (void)setProgressWithUploadProgressOfOperation:(AFURLConnectionOperation *)operation 75 | animated:(BOOL)animated; 76 | 77 | /** 78 | Binds the progress to the download progress of the specified request operation. 79 | 80 | @param operation The request operation. 81 | @param animated `YES` if the change should be animated, `NO` if the change should happen immediately. 82 | */ 83 | - (void)setProgressWithDownloadProgressOfOperation:(AFURLConnectionOperation *)operation 84 | animated:(BOOL)animated; 85 | 86 | @end 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/UIRefreshControl+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | 29 | #import 30 | 31 | @class AFURLConnectionOperation; 32 | 33 | /** 34 | This category adds methods to the UIKit framework's `UIRefreshControl` class. The methods in this category provide support for automatically begining and ending refreshing depending on the loading state of a request operation or session task. 35 | */ 36 | @interface UIRefreshControl (AFNetworking) 37 | 38 | ///----------------------------------- 39 | /// @name Refreshing for Session Tasks 40 | ///----------------------------------- 41 | 42 | /** 43 | Binds the refreshing state to the state of the specified task. 44 | 45 | @param task The task. If `nil`, automatic updating from any previously specified operation will be disabled. 46 | */ 47 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 48 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task; 49 | #endif 50 | 51 | ///---------------------------------------- 52 | /// @name Refreshing for Request Operations 53 | ///---------------------------------------- 54 | 55 | /** 56 | Binds the refreshing state to the execution state of the specified operation. 57 | 58 | @param operation The operation. If `nil`, automatic updating from any previously specified operation will be disabled. 59 | */ 60 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation; 61 | 62 | @end 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/UIRefreshControl+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIRefreshControl+AFNetworking.m 2 | // 3 | // Copyright (c) 2014 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "UIRefreshControl+AFNetworking.h" 24 | 25 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 26 | 27 | #import "AFHTTPRequestOperation.h" 28 | 29 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 30 | #import "AFURLSessionManager.h" 31 | #endif 32 | 33 | @implementation UIRefreshControl (AFNetworking) 34 | 35 | #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 70000 36 | - (void)setRefreshingWithStateOfTask:(NSURLSessionTask *)task { 37 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 38 | 39 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidResumeNotification object:nil]; 40 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidSuspendNotification object:nil]; 41 | [notificationCenter removeObserver:self name:AFNetworkingTaskDidCompleteNotification object:nil]; 42 | 43 | if (task) { 44 | if (task.state == NSURLSessionTaskStateRunning) { 45 | [self beginRefreshing]; 46 | 47 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingTaskDidResumeNotification object:task]; 48 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidCompleteNotification object:task]; 49 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingTaskDidSuspendNotification object:task]; 50 | } else { 51 | [self endRefreshing]; 52 | } 53 | } 54 | } 55 | #endif 56 | 57 | - (void)setRefreshingWithStateOfOperation:(AFURLConnectionOperation *)operation { 58 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 59 | 60 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidStartNotification object:nil]; 61 | [notificationCenter removeObserver:self name:AFNetworkingOperationDidFinishNotification object:nil]; 62 | 63 | if (operation) { 64 | if (![operation isFinished]) { 65 | if ([operation isExecuting]) { 66 | [self beginRefreshing]; 67 | } else { 68 | [self endRefreshing]; 69 | } 70 | 71 | [notificationCenter addObserver:self selector:@selector(af_beginRefreshing) name:AFNetworkingOperationDidStartNotification object:operation]; 72 | [notificationCenter addObserver:self selector:@selector(af_endRefreshing) name:AFNetworkingOperationDidFinishNotification object:operation]; 73 | } 74 | } 75 | } 76 | 77 | #pragma mark - 78 | 79 | - (void)af_beginRefreshing { 80 | dispatch_async(dispatch_get_main_queue(), ^{ 81 | [self beginRefreshing]; 82 | }); 83 | } 84 | 85 | - (void)af_endRefreshing { 86 | dispatch_async(dispatch_get_main_queue(), ^{ 87 | [self endRefreshing]; 88 | }); 89 | } 90 | 91 | @end 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/UIWebView+AFNetworking.h: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.h 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | 29 | #import 30 | 31 | @class AFHTTPRequestSerializer, AFHTTPResponseSerializer; 32 | @protocol AFURLRequestSerialization, AFURLResponseSerialization; 33 | 34 | /** 35 | This category adds methods to the UIKit framework's `UIWebView` class. The methods in this category provide increased control over the request cycle, including progress monitoring and success / failure handling. 36 | 37 | @discussion When using these category methods, make sure to assign `delegate` for the web view, which implements `–webView:shouldStartLoadWithRequest:navigationType:` appropriately. This allows for tapped links to be loaded through AFNetworking, and can ensure that `canGoBack` & `canGoForward` update their values correctly. 38 | */ 39 | @interface UIWebView (AFNetworking) 40 | 41 | /** 42 | The request serializer used to serialize requests made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPRequestSerializer`. 43 | */ 44 | @property (nonatomic, strong) AFHTTPRequestSerializer * requestSerializer; 45 | 46 | /** 47 | The response serializer used to serialize responses made with the `-loadRequest:...` category methods. By default, this is an instance of `AFHTTPResponseSerializer`. 48 | */ 49 | @property (nonatomic, strong) AFHTTPResponseSerializer * responseSerializer; 50 | 51 | /** 52 | Asynchronously loads the specified request. 53 | 54 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 55 | @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. 56 | @param success A block object to be executed when the request finishes loading successfully. This block returns the HTML string to be loaded by the web view, and takes two arguments: the response, and the response string. 57 | @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 58 | */ 59 | - (void)loadRequest:(NSURLRequest *)request 60 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 61 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 62 | failure:(void (^)(NSError *error))failure; 63 | 64 | /** 65 | Asynchronously loads the data associated with a particular request with a specified MIME type and text encoding. 66 | 67 | @param request A URL request identifying the location of the content to load. This must not be `nil`. 68 | @param MIMEType The MIME type of the content. Defaults to the content type of the response if not specified. 69 | @param textEncodingName The IANA encoding name, as in `utf-8` or `utf-16`. Defaults to the response text encoding if not specified. 70 | @param progress A block object to be called when an undetermined number of bytes have been downloaded from the server. This block has no return value and takes three arguments: the number of bytes read since the last time the download progress block was called, the total bytes read, and the total bytes expected to be read during the request, as initially determined by the expected content size of the `NSHTTPURLResponse` object. This block may be called multiple times, and will execute on the main thread. 71 | @param success A block object to be executed when the request finishes loading successfully. This block returns the data to be loaded by the web view and takes two arguments: the response, and the downloaded data. 72 | @param failure A block object to be executed when the request operation finishes unsuccessfully, or that finishes successfully, but encountered an error while parsing the response data. This block has no return value and takes a single argument: the error that occurred. 73 | */ 74 | - (void)loadRequest:(NSURLRequest *)request 75 | MIMEType:(NSString *)MIMEType 76 | textEncodingName:(NSString *)textEncodingName 77 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 78 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 79 | failure:(void (^)(NSError *error))failure; 80 | 81 | @end 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/UIKit+AFNetworking/UIWebView+AFNetworking.m: -------------------------------------------------------------------------------- 1 | // UIWebView+AFNetworking.m 2 | // 3 | // Copyright (c) 2013-2015 AFNetworking (http://afnetworking.com) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import "UIWebView+AFNetworking.h" 24 | 25 | #import 26 | 27 | #if defined(__IPHONE_OS_VERSION_MIN_REQUIRED) 28 | 29 | #import "AFHTTPRequestOperation.h" 30 | #import "AFURLResponseSerialization.h" 31 | #import "AFURLRequestSerialization.h" 32 | 33 | @interface UIWebView (_AFNetworking) 34 | @property (readwrite, nonatomic, strong, setter = af_setHTTPRequestOperation:) AFHTTPRequestOperation *af_HTTPRequestOperation; 35 | @end 36 | 37 | @implementation UIWebView (_AFNetworking) 38 | 39 | - (AFHTTPRequestOperation *)af_HTTPRequestOperation { 40 | return (AFHTTPRequestOperation *)objc_getAssociatedObject(self, @selector(af_HTTPRequestOperation)); 41 | } 42 | 43 | - (void)af_setHTTPRequestOperation:(AFHTTPRequestOperation *)operation { 44 | objc_setAssociatedObject(self, @selector(af_HTTPRequestOperation), operation, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 45 | } 46 | 47 | @end 48 | 49 | #pragma mark - 50 | 51 | @implementation UIWebView (AFNetworking) 52 | 53 | - (AFHTTPRequestSerializer *)requestSerializer { 54 | static AFHTTPRequestSerializer *_af_defaultRequestSerializer = nil; 55 | static dispatch_once_t onceToken; 56 | dispatch_once(&onceToken, ^{ 57 | _af_defaultRequestSerializer = [AFHTTPRequestSerializer serializer]; 58 | }); 59 | 60 | #pragma clang diagnostic push 61 | #pragma clang diagnostic ignored "-Wgnu" 62 | return objc_getAssociatedObject(self, @selector(requestSerializer)) ?: _af_defaultRequestSerializer; 63 | #pragma clang diagnostic pop 64 | } 65 | 66 | - (void)setRequestSerializer:(AFHTTPRequestSerializer *)requestSerializer { 67 | objc_setAssociatedObject(self, @selector(requestSerializer), requestSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 68 | } 69 | 70 | - (AFHTTPResponseSerializer *)responseSerializer { 71 | static AFHTTPResponseSerializer *_af_defaultResponseSerializer = nil; 72 | static dispatch_once_t onceToken; 73 | dispatch_once(&onceToken, ^{ 74 | _af_defaultResponseSerializer = [AFHTTPResponseSerializer serializer]; 75 | }); 76 | 77 | #pragma clang diagnostic push 78 | #pragma clang diagnostic ignored "-Wgnu" 79 | return objc_getAssociatedObject(self, @selector(responseSerializer)) ?: _af_defaultResponseSerializer; 80 | #pragma clang diagnostic pop 81 | } 82 | 83 | - (void)setResponseSerializer:(AFHTTPResponseSerializer *)responseSerializer { 84 | objc_setAssociatedObject(self, @selector(responseSerializer), responseSerializer, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 85 | } 86 | 87 | #pragma mark - 88 | 89 | - (void)loadRequest:(NSURLRequest *)request 90 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 91 | success:(NSString * (^)(NSHTTPURLResponse *response, NSString *HTML))success 92 | failure:(void (^)(NSError *error))failure 93 | { 94 | [self loadRequest:request MIMEType:nil textEncodingName:nil progress:progress success:^NSData *(NSHTTPURLResponse *response, NSData *data) { 95 | NSStringEncoding stringEncoding = NSUTF8StringEncoding; 96 | if (response.textEncodingName) { 97 | CFStringEncoding encoding = CFStringConvertIANACharSetNameToEncoding((CFStringRef)response.textEncodingName); 98 | if (encoding != kCFStringEncodingInvalidId) { 99 | stringEncoding = CFStringConvertEncodingToNSStringEncoding(encoding); 100 | } 101 | } 102 | 103 | NSString *string = [[NSString alloc] initWithData:data encoding:stringEncoding]; 104 | if (success) { 105 | string = success(response, string); 106 | } 107 | 108 | return [string dataUsingEncoding:stringEncoding]; 109 | } failure:failure]; 110 | } 111 | 112 | - (void)loadRequest:(NSURLRequest *)request 113 | MIMEType:(NSString *)MIMEType 114 | textEncodingName:(NSString *)textEncodingName 115 | progress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))progress 116 | success:(NSData * (^)(NSHTTPURLResponse *response, NSData *data))success 117 | failure:(void (^)(NSError *error))failure 118 | { 119 | NSParameterAssert(request); 120 | 121 | if (self.af_HTTPRequestOperation) { 122 | [self.af_HTTPRequestOperation cancel]; 123 | } 124 | 125 | request = [self.requestSerializer requestBySerializingRequest:request withParameters:nil error:nil]; 126 | 127 | self.af_HTTPRequestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 128 | self.af_HTTPRequestOperation.responseSerializer = self.responseSerializer; 129 | 130 | __weak __typeof(self)weakSelf = self; 131 | [self.af_HTTPRequestOperation setDownloadProgressBlock:progress]; 132 | [self.af_HTTPRequestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id __unused responseObject) { 133 | NSData *data = success ? success(operation.response, operation.responseData) : operation.responseData; 134 | 135 | #pragma clang diagnostic push 136 | #pragma clang diagnostic ignored "-Wgnu" 137 | __strong __typeof(weakSelf) strongSelf = weakSelf; 138 | [strongSelf loadData:data MIMEType:(MIMEType ?: [operation.response MIMEType]) textEncodingName:(textEncodingName ?: [operation.response textEncodingName]) baseURL:[operation.response URL]]; 139 | 140 | if ([strongSelf.delegate respondsToSelector:@selector(webViewDidFinishLoad:)]) { 141 | [strongSelf.delegate webViewDidFinishLoad:strongSelf]; 142 | } 143 | 144 | #pragma clang diagnostic pop 145 | } failure:^(AFHTTPRequestOperation * __unused operation, NSError *error) { 146 | if (failure) { 147 | failure(error); 148 | } 149 | }]; 150 | 151 | [self.af_HTTPRequestOperation start]; 152 | 153 | if ([self.delegate respondsToSelector:@selector(webViewDidStartLoad:)]) { 154 | [self.delegate webViewDidStartLoad:self]; 155 | } 156 | } 157 | 158 | @end 159 | 160 | #endif 161 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/Vendor/XMLDocument/SMXMLDocument.h: -------------------------------------------------------------------------------- 1 | /* 2 | The MIT License 3 | 4 | Copyright (c) 2014 Nick Farina 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | */ 24 | 25 | #import 26 | 27 | /* 28 | 29 | SMXMLDocument 30 | ------------- 31 | Created by Nick Farina (nfarina@gmail.com) 32 | Version 1.1 33 | 34 | */ 35 | 36 | // SMXMLDocument is a very handy lightweight XML parser for iOS. 37 | 38 | extern NSString *const SMXMLDocumentErrorDomain; 39 | 40 | @class SMXMLDocument, SMXMLElementChildren, SMXMLElementValueFinder; 41 | 42 | // 43 | // XMLElement class; the workhorse. 44 | // 45 | 46 | @interface SMXMLElement : NSObject 47 | 48 | @property (nonatomic, weak) SMXMLDocument *document; 49 | @property (nonatomic, weak) SMXMLElement *parent; 50 | @property (nonatomic, copy) NSString *name; 51 | @property (nonatomic, retain) NSString *value; 52 | @property (nonatomic, retain) NSArray *children; 53 | @property (nonatomic, retain) NSDictionary *attributes; 54 | @property (nonatomic, readonly) SMXMLElement *firstChild, *lastChild; 55 | @property (nonatomic, readonly) SMXMLElementChildren *all; 56 | @property (nonatomic, readonly) SMXMLElementValueFinder *values; 57 | 58 | - (id)initWithDocument:(SMXMLDocument *)document; 59 | 60 | // 61 | // Method-based document traversing 62 | // 63 | 64 | - (SMXMLElement *)childNamed:(NSString *)name; 65 | - (NSArray *)childrenNamed:(NSString *)name; 66 | - (SMXMLElement *)childWithAttribute:(NSString *)attributeName value:(NSString *)attributeValue; 67 | - (NSString *)attributeNamed:(NSString *)name; 68 | - (SMXMLElement *)descendantWithPath:(NSString *)path; 69 | - (NSString *)valueWithPath:(NSString *)path; 70 | 71 | - (NSString *)fullDescription; // like -description, this writes the document out to an XML string, but doesn't truncate the node values. 72 | - (NSString *)encodedDescription; // like -fullDescription, but this does HTML encoding of element content 73 | 74 | @end 75 | 76 | // 77 | // XMLDocument class; simply adds methods to parse an XML document and remember any errors. 78 | // 79 | 80 | @interface SMXMLDocument : SMXMLElement 81 | 82 | @property (nonatomic, retain) NSError *error; 83 | 84 | - (id)initWithData:(NSData *)data error:(NSError **)outError; 85 | 86 | + (SMXMLDocument *)documentWithData:(NSData *)data error:(NSError **)outError; 87 | 88 | @end 89 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/View/MainView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MainView.h 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import "BaseView.h" 10 | 11 | @interface MainView : BaseView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/View/MainView.m: -------------------------------------------------------------------------------- 1 | // 2 | // MainView.m 3 | // Project_Template 4 | // 5 | // Created by SamSol on 29/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import "MainView.h" 10 | 11 | @interface MainView(){ 12 | 13 | } 14 | 15 | @end 16 | 17 | @implementation MainView 18 | 19 | #pragma mark - Lifecycle 20 | 21 | - (id)init{ 22 | self = [super init]; 23 | 24 | if(self){ 25 | [self loadViewControls]; 26 | [self setViewControlsLayout]; 27 | } 28 | 29 | return self; 30 | } 31 | 32 | -(void)layoutSubviews{ 33 | [super layoutSubviews]; 34 | } 35 | 36 | - (void)dealloc{ 37 | 38 | 39 | } 40 | 41 | #pragma mark - Layout 42 | 43 | -(void)loadViewControls{ 44 | [super loadViewControls]; 45 | 46 | } 47 | 48 | - (void)setViewControlsLayout{ 49 | [super setViewControlsLayout]; 50 | 51 | #if KHideLayOutArea 52 | 53 | #endif 54 | 55 | 56 | } 57 | 58 | #pragma mark - Public Interface 59 | 60 | 61 | #pragma mark - User Interaction 62 | 63 | 64 | #pragma mark - Internal Helpers 65 | 66 | 67 | 68 | @end 69 | -------------------------------------------------------------------------------- /Project_Template/Project_Template/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Project_Template 4 | // 5 | // Created by SamSol on 31/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Project_Template/Project_TemplateTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | com.samsol.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Project_Template/Project_TemplateTests/Project_TemplateTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // Project_TemplateTests.m 3 | // Project_TemplateTests 4 | // 5 | // Created by SamSol on 31/08/15. 6 | // Copyright (c) 2015 SamSol. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface Project_TemplateTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation Project_TemplateTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # iOS_Project_Template 2 | 3 | This is the basic structure to create iOS Universal Single View App in ideal folder structure. You can modify as you want. 4 | 5 | This project contains initial level of ideal project structure and also contains useful macro, app utility and interface utility functions. 6 | 7 | Also added different open source frameworks. 8 | 9 | ![alt tag](https://raw.githubusercontent.com/samsol38/iOS_Project_Template/master/Project_Structure.png) 10 | --------------------------------------------------------------------------------