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
| // O(n2) | |
| func selectionSort(array: [Int]) -> [Int] { | |
| var copy = array | |
| for index in 0..<copy.count - 1 { | |
| let subarray = copy.suffix(from: index + 1) | |
| let min = subarray.min()! | |
| if min < copy[index] { | |
| let indexOfMin = subarray.firstIndex(of: min)! |
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
| <?xml version="1.0" encoding="UTF-8" standalone="no"?> | |
| <document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="2.0" toolsVersion="3084" systemVersion="12C60" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="2"> | |
| <dependencies> | |
| <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="2083"/> | |
| </dependencies> | |
| <scenes> | |
| <!--View Controller--> | |
| <scene sceneID="5"> | |
| <objects> | |
| <viewController id="2" customClass="TTViewController" sceneMemberID="viewController"> |
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
| //Class will be declared later | |
| @class CustomClass; | |
| //Define the protocol for the delegate | |
| @protocol CustomClassDelegate | |
| @required | |
| //Required methods go here | |
| //If there are optional functions, they go here |
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. |
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
| //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 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
| 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 | |
| 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
| 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) |
OlderNewer