Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
maximkhatskevich committed Mar 11, 2017
2 parents 501fbc4 + abc3538 commit 9472f1d
Show file tree
Hide file tree
Showing 10 changed files with 276 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Info/MKHHelpers.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.1</string>
<string>1.1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>2</string>
<string>3</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion MKHHelpers.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = 'MKHHelpers'
s.version = '1.0.1'
s.version = '1.1.0'
s.summary = 'Set of generic helpers for Cocoa and Cocoa Touch.'
s.homepage = 'https://github.com/maximkhatskevich/#{s.name}'

Expand Down
42 changes: 31 additions & 11 deletions MKHHelpers.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// !$*UTF8*$!
{
archiveVersion = "";
classes = "";
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {

Expand All @@ -10,6 +11,10 @@
454BF9EE553CAB9B0F82BEDF /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7EA76E44E0CFFBB1B11ACBC9 /* UIKit.framework */; };
560BE34117E964DAAED580E2 /* String+MKHHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A93B0E9C8AA09628E00E8B20 /* String+MKHHelpers.swift */; };
8E228908F4479937C109C9B2 /* UIViewController+MKHHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7CC366BD5515060A247FE44 /* UIViewController+MKHHelpers.swift */; };
946C03231E2E381500FA41B5 /* UIButton+MKHHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946C03221E2E381500FA41B5 /* UIButton+MKHHelpers.swift */; };
946C03271E2E40CC00FA41B5 /* Array+MKHHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 946C03261E2E40CC00FA41B5 /* Array+MKHHelpers.swift */; };
94A3EABD1E32B2EE0053164B /* UIStackView+MKHHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A3EABC1E32B2EE0053164B /* UIStackView+MKHHelpers.swift */; };
94A3EAC11E32C26D0053164B /* Stick.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A3EAC01E32C26D0053164B /* Stick.swift */; };
A3DECD10F6D569EF293E6F3A /* UIScrollView+MKHHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 35C33DECA30F5918D5B90808 /* UIScrollView+MKHHelpers.swift */; };
AC0E87E64CF73768619EEB3F /* UIView+MKHHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D884B414ED9E47BFCC5F945 /* UIView+MKHHelpers.swift */; };
B5A3BC0AB97E61AB4C1BDFCB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5AB4E6C4A1186A4D8C1CF1DA /* Foundation.framework */; };
Expand All @@ -22,10 +27,14 @@
35C33DECA30F5918D5B90808 /* UIScrollView+MKHHelpers.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "UIScrollView+MKHHelpers.swift"; sourceTree = "<group>"; };
5A7BD39744F7DAB011A0DFCD /* MiscUI.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = MiscUI.swift; sourceTree = "<group>"; };
5AB4E6C4A1186A4D8C1CF1DA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
6CCC1EDDC76E356041ECA12E /* MKHHelpers. */ = {isa = PBXFileReference; includeInIndex = 0; path = MKHHelpers.; sourceTree = BUILT_PRODUCTS_DIR; };
6CCC1EDDC76E356041ECA12E /* MKHHelpers. */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.framework; name = MKHHelpers.; path = MKHHelpers.framework; sourceTree = BUILT_PRODUCTS_DIR; };
7D884B414ED9E47BFCC5F945 /* UIView+MKHHelpers.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "UIView+MKHHelpers.swift"; sourceTree = "<group>"; };
7EA76E44E0CFFBB1B11ACBC9 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
87543EACBDDDBCEF11BEA575 /* MKHHelpers.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = MKHHelpers.h; sourceTree = "<group>"; };
946C03221E2E381500FA41B5 /* UIButton+MKHHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIButton+MKHHelpers.swift"; sourceTree = "<group>"; };
946C03261E2E40CC00FA41B5 /* Array+MKHHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Array+MKHHelpers.swift"; sourceTree = "<group>"; };
94A3EABC1E32B2EE0053164B /* UIStackView+MKHHelpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIStackView+MKHHelpers.swift"; sourceTree = "<group>"; };
94A3EAC01E32C26D0053164B /* Stick.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Stick.swift; sourceTree = "<group>"; };
A7CC366BD5515060A247FE44 /* UIViewController+MKHHelpers.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "UIViewController+MKHHelpers.swift"; sourceTree = "<group>"; };
A93B0E9C8AA09628E00E8B20 /* String+MKHHelpers.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "String+MKHHelpers.swift"; sourceTree = "<group>"; };
FA2B7B202691A94BF1827BCE /* UIImage+MKHHelpers.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = "UIImage+MKHHelpers.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -84,7 +93,6 @@
children = (
87543EACBDDDBCEF11BEA575 /* MKHHelpers.h */,
);
name = "Src-Extra";
path = "Src-Extra";
sourceTree = "<group>";
};
Expand All @@ -97,9 +105,12 @@
FA2B7B202691A94BF1827BCE /* UIImage+MKHHelpers.swift */,
35C33DECA30F5918D5B90808 /* UIScrollView+MKHHelpers.swift */,
7D884B414ED9E47BFCC5F945 /* UIView+MKHHelpers.swift */,
94A3EABC1E32B2EE0053164B /* UIStackView+MKHHelpers.swift */,
A7CC366BD5515060A247FE44 /* UIViewController+MKHHelpers.swift */,
946C03221E2E381500FA41B5 /* UIButton+MKHHelpers.swift */,
946C03261E2E40CC00FA41B5 /* Array+MKHHelpers.swift */,
94A3EAC01E32C26D0053164B /* Stick.swift */,
);
name = Src;
path = Src;
sourceTree = "<group>";
};
Expand Down Expand Up @@ -132,6 +143,11 @@
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0700;
ORGANIZATIONNAME = "Maxim Khatskevich";
TargetAttributes = {
C269D145464FD1E09559A396 = {
DevelopmentTeam = UJA88X59XP;
};
};
};
buildConfigurationList = F2A5AD51C149AB8B6723E206 /* Build configuration list for PBXProject "MKHHelpers" */;
compatibilityVersion = "Xcode 3.2";
Expand Down Expand Up @@ -159,7 +175,11 @@
F9163842E07FEB3EC72933DF /* MiscUI.swift in Sources */,
560BE34117E964DAAED580E2 /* String+MKHHelpers.swift in Sources */,
C4E183F7F9B7CE37A2D1204A /* UIImage+MKHHelpers.swift in Sources */,
946C03231E2E381500FA41B5 /* UIButton+MKHHelpers.swift in Sources */,
A3DECD10F6D569EF293E6F3A /* UIScrollView+MKHHelpers.swift in Sources */,
946C03271E2E40CC00FA41B5 /* Array+MKHHelpers.swift in Sources */,
94A3EABD1E32B2EE0053164B /* UIStackView+MKHHelpers.swift in Sources */,
94A3EAC11E32C26D0053164B /* Stick.swift in Sources */,
AC0E87E64CF73768619EEB3F /* UIView+MKHHelpers.swift in Sources */,
8E228908F4479937C109C9B2 /* UIViewController+MKHHelpers.swift in Sources */,
);
Expand All @@ -172,12 +192,12 @@
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UJA88X59XP;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 2;
DYLIB_CURRENT_VERSION = 3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -219,7 +239,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
Expand Down Expand Up @@ -269,7 +289,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
COPY_PHASE_STRIP = YES;
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -294,12 +314,12 @@
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CURRENT_PROJECT_VERSION = 2;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = UJA88X59XP;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 2;
DYLIB_CURRENT_VERSION = 3;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down
21 changes: 21 additions & 0 deletions Src/Array+MKHHelpers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// Array+MKHHelpers.swift
// MKHHelpers
//
// Created by Maxim Khatskevich on 1/17/17.
// Copyright © 2017 Maxim Khatskevich. All rights reserved.
//

import Foundation

//===

public
extension Array
{
mutating
func removeFirst() -> Element?
{
return (count > 0 ? remove(at: 0) : nil)
}
}
45 changes: 45 additions & 0 deletions Src/Stick.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// Stick.swift
// MKHHelpers
//
// Created by Maxim Khatskevich on 1/20/17.
// Copyright © 2017 Maxim Khatskevich. All rights reserved.
//

import Foundation

//===

public
enum Stick
{
@discardableResult
public
static
func with<T: AnyObject>(
_ object: T,
configure: (_: T) -> Void
) -> T
{
configure(object)

//===

return object
}
}

//===

infix operator <|

@discardableResult
public
func <| <T: AnyObject>(object: T, configure: (_: T) -> Void) -> T
{
configure(object)

//===

return object
}
25 changes: 25 additions & 0 deletions Src/UIButton+MKHHelpers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// UIButton+MKHHelpers.swift
// MKHHelpers
//
// Created by Maxim Khatskevich on 1/17/17.
// Copyright © 2017 Maxim Khatskevich. All rights reserved.
//

import UIKit

//===

public
extension UIButton
{
@discardableResult
func image(_ i: UIImage?, for state: UIControlState = .normal) -> Self
{
setImage(i, for: state)

//===

return self
}
}
25 changes: 25 additions & 0 deletions Src/UIStackView+MKHHelpers.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// UIStackView+MKHHelpers.swift
// MKHHelpers
//
// Created by Maxim Khatskevich on 1/20/17.
// Copyright © 2017 Maxim Khatskevich. All rights reserved.
//

import UIKit

//===

@available(iOS 9.0, *)
public
extension UIStackView
{
@discardableResult
func sv(_ views: UIView...)
{
for v in views
{
addArrangedSubview(v)
}
}
}
97 changes: 88 additions & 9 deletions Src/UIView+MKHHelpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,84 @@ import UIKit
public
extension UIView
{
private
func collectAllSubviews(into list: inout [UIView])
var isVisible: Bool
{
for sv in subviews
get
{
list.append(sv)

//===

sv.collectAllSubviews(into: &list)
return !isHidden
}

set(newValue)
{
isHidden = !newValue
}
}
}

//===

public
extension UIView
{
@discardableResult
func add(on superview: UIView, _ translatesAutoresizing: Bool = false) -> Self
{
superview.addSubview(self)

//===

translatesAutoresizingMaskIntoConstraints = translatesAutoresizing

//===

return self
}
}

//===

public
extension UIView
{
@available(iOS 9.0, *)
@discardableResult
func add(on stackView: UIStackView) -> Self
{
stackView.addArrangedSubview(self)

//===

return self
}

public
@available(iOS 9.0, *)
@discardableResult
func remove(from stackView: UIStackView) -> Self
{
stackView.removeArrangedSubview(self)

//===

return self
}
}

//===

public
extension UIView
{
func removeAllConstraints()
{
removeConstraints(constraints)
}
}

//===

public
extension UIView
{
func allSubviews() -> [UIView]
{
var result: [UIView] = []
Expand All @@ -39,4 +103,19 @@ extension UIView

return result
}

//===

private
func collectAllSubviews(into list: inout [UIView])
{
for sv in subviews
{
list.append(sv)

//===

sv.collectAllSubviews(into: &list)
}
}
}
Loading

0 comments on commit 9472f1d

Please sign in to comment.