Skip to content

Instantly share code, notes, and snippets.

{
"points" : [
{
"name" : "Motor DE Horizontal",
"enabled" : true,
"location" : {
"number" : 2,
"plane" : "H"
}
},
@AviTsadok
AviTsadok / testPerformanceMethod.swift
Created June 27, 2019 17:39
Test Performance Method
func testPerforamnce() {
let obj = ProcessingImageService()
let image = UIImage(named: "myImage")
measure(metrics: [XCTClockMetric(), // to measure time
XCTCPUMetric(), // to measure cpu cycles
XCTStorageMetric(), // to measure storage consuming
XCTMemoryMetric()]) { // to measeure RAM consuming
obj.processImage(image: image) // this is the heavy process
}
@AviTsadok
AviTsadok / CalendarConnector.swift
Created June 28, 2019 11:46
Calendar Connector File
protocol CalendarConnectorProtocol {
func isAuthorized()->Bool
func requestAccess(completion: @escaping EKEventStoreRequestAccessCompletionHandler)
func fetch(fromDate : Date, toDate : Date, calendarsExclude : [String], completion : ([EKEventDTO])->Void)
func openAddEventScreen(fromController controller : Any, atDate date : Date, inCalendarID : String, completion : @escaping AddCalendarEventCompletionBlock)
func openEventScreen(eventIdentifier : String, fromController controller : Any)
func getAllCalendars()->[EKCalendarDTO]
}
@AviTsadok
AviTsadok / CalendarService.swift
Last active June 28, 2019 11:59
Calendar Service
protocol CalendarServiceProtocol {
func getVisibleCalendarsIDs()->[String]
func isEventInThePast(eventID : String)->Bool
func isEventLastForSeveralDays(eventID : String)->Bool
func getAllEvents()->[EKEventDTO]
func calendarDataChanged()
}
class CalendarService: NSObject, CalendarServiceProtocol {
@AviTsadok
AviTsadok / CalendarScreenInteracot.swift
Created June 28, 2019 12:07
Calendar Interactor Example
protocol CalendarScreenInteractorProtocol {
func calendarDataUpdated()
func requestAccess(completion: @escaping EKEventStoreRequestAccessCompletionHandler)
func getAllData()->[CalendarDisplayModel]
func hasPermission()->Bool
func openEvent(eventID : String)
func markCalendarAsVisible(calendarID : String)
func markCalendarAsHidden(calendarID : String)
}
@AviTsadok
AviTsadok / CalendarScreenPresenter.swift
Created June 28, 2019 12:36
Calendar Screen Presenter Example
protocl CalendarScreenPresenterProtocol {
func dataUpdated()
func onViewDidLoad()
func onMenuButtonTap()
func onEventTap(atIndexPath indexPath : IndexPath)
func userScrolledToNextPage()
}
class CalendarScreenPresenter : CalendarScreenPresenterProtocol {
}
@AviTsadok
AviTsadok / CalendarViewController.swift
Created June 28, 2019 12:42
Calendar View Controller Protocol Example
protocol CalendarViewControllerProtocol {
func reloadData()
func reloadCell(atIndexPath indexPath : IndexPath)
func showNewBadge()
func hideNewBadge()
func expandDaysSelector()
}
class CalendarViewController : UIViewController, CalendarViewControllerProtocol {
}
@AviTsadok
AviTsadok / SkinHandler.swift
Created June 29, 2019 19:07
Skin Handler Example
class Skin {
var titleFont : UIFont!
var titleColor : UIColor!
var subTitleFont : UIFont!
var subTitleColor : UIColor!
var openPopupDuration : TimeInterval!
var backgroundColor : UIColor!
}
class SkinHandler {
@AviTsadok
AviTsadok / ContactStatusOptions.swift
Created July 6, 2019 21:25
Contact Status Example
typedef NS_OPTIONS(NSUInteger, ContactStatus) {
Deleted = (1 << 0), // => 00000001
Archived = (1 << 1), // => 00000010
Exists = (1 << 2) // => 00000100
};
@AviTsadok
AviTsadok / ContactStatusOR.swift
Created July 6, 2019 21:26
Contact Status OR Example
ContactStatus status = Deleted | Archived; // => 00000011