Skip to content

Commit 62d98ac

Browse files
committed
Merge branch 'Swift3' of https://github.com/goktugyil/EZSwiftExtensions into swift3xcode8
# Conflicts: # EZSwiftExtensionsTests/DictionaryTests.swift # EZSwiftExtensionsTests/EZSwiftExtensionsTestsNSURL.swift # EZSwiftExtensionsTests/EZSwiftExtensionsTestsString.swift # EZSwiftExtensionsTests/NSDateTests.swift # Sources/ArrayExtensions.swift # Sources/BlockButton.swift # Sources/BlockLongPress.swift # Sources/BlockPan.swift # Sources/BlockPinch.swift # Sources/BlockSwipe.swift # Sources/BlockTap.swift # Sources/BlockWebView.swift # Sources/BoolExtensions.swift # Sources/CGFloatExtensions.swift # Sources/DoubleExtensions.swift # Sources/EZSwiftFunctions.swift # Sources/ErrorTypeExtensions.swift # Sources/NSAttributedStringExtensions.swift # Sources/NSDateExtensions.swift # Sources/NSURLExtensions.swift # Sources/NSUserDefaultsExtension.swift # Sources/StringExtensions.swift # Sources/UIDeviceExtensions.swift # Sources/UIImageExtensions.swift # Sources/UISliderExtensions.swift # Sources/UIStoryboardExtensions.swift # Sources/UITextViewExtensions.swift # Sources/UIViewControllerExtensions.swift # Sources/UIViewExtensions.swift
2 parents 2018508 + b049193 commit 62d98ac

26 files changed

+286
-56
lines changed

EZSwiftExtensions.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,7 @@
10891089
PRODUCT_NAME = EZSwiftExtensions;
10901090
SDKROOT = appletvos;
10911091
SKIP_INSTALL = YES;
1092+
SWIFT_VERSION = 3.0;
10921093
TVOS_DEPLOYMENT_TARGET = 9.0;
10931094
};
10941095
name = Debug;
@@ -1108,6 +1109,7 @@
11081109
PRODUCT_NAME = EZSwiftExtensions;
11091110
SDKROOT = appletvos;
11101111
SKIP_INSTALL = YES;
1112+
SWIFT_VERSION = 3.0;
11111113
TVOS_DEPLOYMENT_TARGET = 9.0;
11121114
};
11131115
name = Release;
@@ -1120,6 +1122,7 @@
11201122
PRODUCT_BUNDLE_IDENTIFIER = com.gbf.EZSwiftExtensions.EZSwiftExtensionsTests;
11211123
PRODUCT_NAME = EZSwiftExtensionsTest;
11221124
SDKROOT = appletvos;
1125+
SWIFT_VERSION = 3.0;
11231126
};
11241127
name = Debug;
11251128
};
@@ -1131,6 +1134,7 @@
11311134
PRODUCT_BUNDLE_IDENTIFIER = com.gbf.EZSwiftExtensions.EZSwiftExtensionsTests;
11321135
PRODUCT_NAME = EZSwiftExtensionsTest;
11331136
SDKROOT = appletvos;
1137+
SWIFT_VERSION = 3.0;
11341138
};
11351139
name = Release;
11361140
};

EZSwiftExtensionsExample.xcodeproj/project.pbxproj

+16-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
C48E3F661D902B6700ED2DF7 /* NSUserDefaultsExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C48E3F651D902B6700ED2DF7 /* NSUserDefaultsExtension.swift */; };
1011
C85840ED1C43B05200595696 /* NSURLExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C85840EC1C43B05200595696 /* NSURLExtensions.swift */; };
1112
E10A79321D6F2ED700735549 /* UIApplicationExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E10A79311D6F2ED700735549 /* UIApplicationExtensions.swift */; };
1213
E10A79371D6F4BDB00735549 /* UITextFieldExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E10A79361D6F4BDB00735549 /* UITextFieldExtensions.swift */; };
@@ -61,6 +62,7 @@
6162
/* End PBXBuildFile section */
6263

6364
/* Begin PBXFileReference section */
65+
C48E3F651D902B6700ED2DF7 /* NSUserDefaultsExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NSUserDefaultsExtension.swift; path = Sources/NSUserDefaultsExtension.swift; sourceTree = SOURCE_ROOT; };
6466
C85840EC1C43B05200595696 /* NSURLExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NSURLExtensions.swift; path = Sources/NSURLExtensions.swift; sourceTree = SOURCE_ROOT; };
6567
E10A79311D6F2ED700735549 /* UIApplicationExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UIApplicationExtensions.swift; path = Sources/UIApplicationExtensions.swift; sourceTree = SOURCE_ROOT; };
6668
E10A79361D6F4BDB00735549 /* UITextFieldExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = UITextFieldExtensions.swift; path = Sources/UITextFieldExtensions.swift; sourceTree = SOURCE_ROOT; };
@@ -135,6 +137,7 @@
135137
E1839E041BF79974002212C6 /* BlockLongPress.swift */,
136138
E1839E051BF79974002212C6 /* BlockPan.swift */,
137139
E1839E061BF79974002212C6 /* BlockPinch.swift */,
140+
C48E3F651D902B6700ED2DF7 /* NSUserDefaultsExtension.swift */,
138141
E1839E071BF79974002212C6 /* BlockSwipe.swift */,
139142
E1839E081BF79974002212C6 /* BlockTap.swift */,
140143
E1839E091BF79974002212C6 /* BlockWebView.swift */,
@@ -237,7 +240,7 @@
237240
E1839DAD1BF79335002212C6 /* Project object */ = {
238241
isa = PBXProject;
239242
attributes = {
240-
LastUpgradeCheck = 0700;
243+
LastUpgradeCheck = 0800;
241244
ORGANIZATIONNAME = "Goktug Yilmaz";
242245
TargetAttributes = {
243246
E1839DB41BF79335002212C6 = {
@@ -292,6 +295,7 @@
292295
E1839E351BF79974002212C6 /* UIImageViewExtensions.swift in Sources */,
293296
E1839E371BF79974002212C6 /* UITextViewExtensions.swift in Sources */,
294297
E1839E2F1BF79974002212C6 /* UIButtonExtensions.swift in Sources */,
298+
C48E3F661D902B6700ED2DF7 /* NSUserDefaultsExtension.swift in Sources */,
295299
E1587FB01CCA41F400A0B071 /* UISwitchExtensions.swift in Sources */,
296300
E10A79491D6F51E200735549 /* NSDictionaryExtensions.swift in Sources */,
297301
E1839E301BF79974002212C6 /* UIColoredView.swift in Sources */,
@@ -368,8 +372,10 @@
368372
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
369373
CLANG_WARN_EMPTY_BODY = YES;
370374
CLANG_WARN_ENUM_CONVERSION = YES;
375+
CLANG_WARN_INFINITE_RECURSION = YES;
371376
CLANG_WARN_INT_CONVERSION = YES;
372377
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
378+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
373379
CLANG_WARN_UNREACHABLE_CODE = YES;
374380
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
375381
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -396,6 +402,7 @@
396402
ONLY_ACTIVE_ARCH = YES;
397403
SDKROOT = iphoneos;
398404
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
405+
SWIFT_VERSION = 3.0;
399406
TARGETED_DEVICE_FAMILY = "1,2";
400407
};
401408
name = Debug;
@@ -413,8 +420,10 @@
413420
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
414421
CLANG_WARN_EMPTY_BODY = YES;
415422
CLANG_WARN_ENUM_CONVERSION = YES;
423+
CLANG_WARN_INFINITE_RECURSION = YES;
416424
CLANG_WARN_INT_CONVERSION = YES;
417425
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
426+
CLANG_WARN_SUSPICIOUS_MOVE = YES;
418427
CLANG_WARN_UNREACHABLE_CODE = YES;
419428
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
420429
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
@@ -433,6 +442,8 @@
433442
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
434443
MTL_ENABLE_DEBUG_INFO = NO;
435444
SDKROOT = iphoneos;
445+
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
446+
SWIFT_VERSION = 3.0;
436447
TARGETED_DEVICE_FAMILY = "1,2";
437448
VALIDATE_PRODUCT = YES;
438449
};
@@ -442,23 +453,27 @@
442453
isa = XCBuildConfiguration;
443454
buildSettings = {
444455
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
456+
DEVELOPMENT_TEAM = "";
445457
INFOPLIST_FILE = EZSwiftExtensions/Info.plist;
446458
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
447459
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
448460
PRODUCT_BUNDLE_IDENTIFIER = com.gbf.EZSwiftExtensions;
449461
PRODUCT_NAME = EZSwiftExtensionsExample;
462+
SWIFT_VERSION = 3.0;
450463
};
451464
name = Debug;
452465
};
453466
E1839DC91BF79335002212C6 /* Release */ = {
454467
isa = XCBuildConfiguration;
455468
buildSettings = {
456469
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
470+
DEVELOPMENT_TEAM = "";
457471
INFOPLIST_FILE = EZSwiftExtensions/Info.plist;
458472
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
459473
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
460474
PRODUCT_BUNDLE_IDENTIFIER = com.gbf.EZSwiftExtensions;
461475
PRODUCT_NAME = EZSwiftExtensionsExample;
476+
SWIFT_VERSION = 3.0;
462477
};
463478
name = Release;
464479
};

EZSwiftExtensionsExample/AppDelegate.swift

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,34 @@ import UIKit
1212
class AppDelegate: UIResponder, UIApplicationDelegate {
1313
var window: UIWindow?
1414

15-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
15+
private func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
1616
// Override point for customization after application launch.
1717
return true
1818
}
1919

20-
func applicationWillResignActive(application: UIApplication) {
20+
func applicationWillResignActive(_ application: UIApplication) {
2121
// Sent when the application is about to move from active to inactive state.
2222
// This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message)
2323
// or when the user quits the application and it begins the transition to the background state.
2424
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
2525
}
2626

27-
func applicationDidEnterBackground(application: UIApplication) {
27+
func applicationDidEnterBackground(_ application: UIApplication) {
2828
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information
2929
// to restore your application to its current state in case it is terminated later.
3030
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
3131
}
3232

33-
func applicationWillEnterForeground(application: UIApplication) {
33+
func applicationWillEnterForeground(_ application: UIApplication) {
3434
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
3535
}
3636

37-
func applicationDidBecomeActive(application: UIApplication) {
37+
func applicationDidBecomeActive(_ application: UIApplication) {
3838
// Restart any tasks that were paused (or not yet started) while the application was inactive.
3939
// If the application was previously in the background, optionally refresh the user interface.
4040
}
4141

42-
func applicationWillTerminate(application: UIApplication) {
42+
func applicationWillTerminate(_ application: UIApplication) {
4343
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
4444
}
4545
}

EZSwiftExtensionsExample/Assets.xcassets/AppIcon.appiconset/Contents.json

+20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "20x20",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "20x20",
11+
"scale" : "3x"
12+
},
313
{
414
"idiom" : "iphone",
515
"size" : "29x29",
@@ -30,6 +40,16 @@
3040
"size" : "60x60",
3141
"scale" : "3x"
3242
},
43+
{
44+
"idiom" : "ipad",
45+
"size" : "20x20",
46+
"scale" : "1x"
47+
},
48+
{
49+
"idiom" : "ipad",
50+
"size" : "20x20",
51+
"scale" : "2x"
52+
},
3353
{
3454
"idiom" : "ipad",
3555
"size" : "29x29",

EZSwiftExtensionsExample/Base.lproj/Main.storyboard

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="16A319" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
33
<dependencies>
44
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
67
</dependencies>
78
<scenes>
89
<!--View Controller-->
@@ -14,9 +15,9 @@
1415
<viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
1516
</layoutGuides>
1617
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
17-
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
18+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1819
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
19-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
20+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2021
</view>
2122
</viewController>
2223
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>

EZSwiftExtensionsTests/CGFloatTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class CGFloatTests: XCTestCase {
1818
degrees = 360
1919
}
2020

21-
func testToggle() {
22-
XCTAssertEqual(radians, degrees.degreesToRadians())
21+
func testConversion() {
22+
XCTAssertEqual(radians, degrees.toRadians())
2323
}
2424
}

EZSwiftExtensionsTests/DictionaryTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class DictionaryTests: XCTestCase {
9090
}
9191

9292
func testJSON () {
93-
let jsonDic = NSDictionary(dictionary: ["name": "John", "surname": "Smith", "age": 35.0, "married": NSNumber.init(value: true as Bool), "children": 3])
93+
let jsonDic = NSDictionary(dictionary: ["name": "John", "surname": "Smith", "age": 35.0, "married": NSNumber(value: true), "children": 3])
9494
let jsonString = jsonDic.formatJSON()
9595
XCTAssertNotNil(jsonString)
9696
let secondJsonDic = NSDictionary(json: jsonString!)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
//
2+
// EZSwiftExtensionsTestsNSURL.swift
3+
// EZSwiftExtensions
4+
//
5+
// Created by furuyan on 2016/03/02.
6+
// Copyright © 2016年 Goktug Yilmaz. All rights reserved.
7+
//
8+
9+
import XCTest
10+
@testable import EZSwiftExtensions
11+
12+
class EZSwiftExtensionsTestsNSURL: XCTestCase {
13+
func testQueryParameters() {
14+
let url = URL(string: "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=facebook")
15+
if let queryParameters = url?.queryParameters {
16+
XCTAssertEqual(queryParameters["v"], Optional("1.0"))
17+
XCTAssertEqual(queryParameters["q"], Optional("facebook"))
18+
XCTAssertEqual(queryParameters["other"], nil)
19+
}
20+
}
21+
22+
func testRemote() {
23+
var len: Int64?
24+
var support: Bool?
25+
let urlResume = URL(string: "http://httpbin.org/range/1024")!
26+
let urlSize = URL(string: "http://httpbin.org/bytes/1024")!
27+
let group = DispatchGroup()
28+
group.enter()
29+
urlSize.remoteSize({ (contentLength: Int64) in
30+
len = contentLength
31+
group.leave()
32+
})
33+
group.enter()
34+
urlResume.supportsResume({ (doesSupport: Bool) in
35+
support = doesSupport
36+
group.leave()
37+
})
38+
_ = group.wait(timeout: DispatchTime.now() + Double(Int64(30 * NSEC_PER_SEC)) / Double(NSEC_PER_SEC))
39+
XCTAssertEqual(len, 1024)
40+
XCTAssertEqual(support, true)
41+
}
42+
43+
func testIsSame() {
44+
let url1 = URL(string: "http://google.com/")!
45+
let url2 = URL(string: "http://www.google.com")!
46+
XCTAssertTrue(url1.isSameWithURL(url2))
47+
}
48+
49+
func testFileFunctions() {
50+
// FIXME: Better implementation to address a real existing file url
51+
let documentsPath = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.libraryDirectory, FileManager.SearchPathDomainMask.userDomainMask, true)[0]
52+
let documentsURL = URL(fileURLWithPath: documentsPath)
53+
54+
XCTAssertTrue(documentsURL.fileIsDirectory)
55+
XCTAssertNotNil(documentsURL.fileCreationDate)
56+
XCTAssertNotNil(documentsURL.fileModifiedDate)
57+
XCTAssertTrue(documentsURL.fileIsWritable)
58+
XCTAssertEqual(documentsURL.fileSizeValue, -1)
59+
60+
}
61+
62+
63+
}

0 commit comments

Comments
 (0)