Skip to content

Instantly share code, notes, and snippets.

@mazen-kasser
mazen-kasser / StepperControl.swift
Last active June 30, 2022 09:41
Stepper component based on `UIStepper` control with having a label as the divider image.
import UIKit
/// Stepper component based on `UIStepper` control.
///
/// - Parameters:
/// - onClick, closure returns the final `value`
/// - isContinuous, default = YES. value change events are sent any time the value changes during interaction.
/// - autorepeat, default = YES. press & hold repeatedly alters value.
/// - wraps, default = NO. value wraps from min <-> max.
/// - value, default = 0. sends UIControlEventValueChanged. clamped to min/max
import UIKit
extension UITableView {
/// Layout `UITableView.headerView` with autolayout.
func layoutTableHeaderView() {
guard let headerView = tableHeaderView else { return }
layout(headerView)
self.tableHeaderView = headerView
}
@advantis
advantis / NSManagedObject+ADVCopying.h
Created November 25, 2013 14:34
NSManagedObject category for creating deep copy in another context
//
// Copyright © 2013 Yuri Kotov
//
#import <CoreData/CoreData.h>
@interface NSManagedObject (ADVCopying)
- (instancetype) adv_copyInContext:(NSManagedObjectContext *)context;