This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // | |
| // ViewController.swift | |
| // CollectionViewPractice | |
| // | |
| // Created by nTom on 2020/10/26. | |
| // Copyright © 2020 CollectionViewPractice. All rights reserved. | |
| // | |
| import UIKit | |
| import SnapKit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | |
| return CGSize(width: categoryTitles[indexPath.item].size(withAttributes: [NSAttributedString.Key.font : UIFont.systemFont(ofSize: 14)]).width + 20, height: 32) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| class APIService : NSObject { | |
| private let sourcesURL = URL(string: "http://dummy.restapiexample.com/api/v1/employees")! | |
| func apiToGetEmployeeData(completion : @escaping (Employees) -> ()){ | |
| URLSession.shared.dataTask(with: sourcesURL) { (data, urlResponse, error) in | |
| if let data = data { | |
| let jsonDecoder = JSONDecoder() | |
| let empData = try! jsonDecoder.decode(Employees.self, from: data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Foundation | |
| class APIService : NSObject { | |
| private let sourcesURL = URL(string: "http://dummy.restapiexample.com/api/v1/employees")! | |
| func apiToGetEmployeeData(completion : @escaping (Employees) -> ()){ | |
| URLSession.shared.dataTask(with: sourcesURL) { (data, urlResponse, error) in | |
| if let data = data { | |
| let jsonDecoder = JSONDecoder() | |
| let empData = try! jsonDecoder.decode(Employees.self, from: data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| final class PageViewControllerSegmentedAdapter: NSObject { | |
| private let pageViewController: UIPageViewController | |
| fileprivate let segmentControl: UISegmentedControl | |
| fileprivate let viewControllers: [UIViewController] | |
| fileprivate var selectedIndex: Int = 0 | |
| init(pageViewController: UIPageViewController, segmentControl: UISegmentedControl, viewControllers: [UIViewController]) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extension NSDate{ | |
| convenience | |
| init(inputDate: NSDate){ | |
| let calendar = NSCalendar.currentCalendar() | |
| let timeZone = NSTimeZone.systemTimeZone() | |
| calendar.timeZone = timeZone | |
| let comps = calendar.components([NSCalendarUnit.Year, NSCalendarUnit.Month, NSCalendarUnit.Day ], fromDate: inputDate) | |
| comps.hour = 0 | |
| comps.minute = 0 | |
| comps.second = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| /////////////// | |
| // View Cell // | |
| /////////////// | |
| protocol SwitchWithTextCellDataSource { | |
| var title: String { get } | |
| var switchOn: Bool { get } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Passing Data Between ViewControllers Using Closure | |
| //In this model, i am considering two viewController i-e PresentViewController and ParentViewController. Closure is used to pass the data from PresentVC to ParentVC after the dismiss of PersentVC. | |
| //PresentViewController | |
| //Declaration of closure and assigning to completionHandler | |
| typealias sourceClosure = ((_ source: DataModel?) -> Void) | |
| var sourceCompletionHandler: sourceClosure? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #import <Foundation/Foundation.h> | |
| @interface MyNetwork : NSObject | |
| - (NSData* )httpRequestWithURL:(NSURL *)url httpMethod:(NSString *)httpMethod body:(NSData *)body contentType:(NSString *)contentType error:(NSError **)error; | |
| @end | |
| @implementation MyNetwork |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| override func viewDidLayoutSubviews() { | |
| super.viewDidLayoutSubviews() | |
| guard let headerView = tableView.tableHeaderView else { | |
| return | |
| } | |
| // The table view header is created with the frame size set in | |
| // the Storyboard. Calculate the new size and reset the header | |
| // view to trigger the layout. |