Skip to content

Commit fea29f8

Browse files
committed
Xcode 6 Beta 6 changes
1 parent 6fccca2 commit fea29f8

16 files changed

+230
-248
lines changed

ExSwift.podspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Pod::Spec.new do |s|
22
s.name = "ExSwift"
3-
s.version = "0.1.8"
4-
s.summary = "JavaScript (Lo-Dash, Underscore) & Ruby inspired set of Swift extensions for standard types and classes."
3+
s.version = "0.1.9"
4+
s.summary = "Set of Swift extensions for standard types and classes."
55
s.homepage = "https://github.com/pNre/ExSwift"
66
s.license = { :type => 'BSD', :file => 'LICENSE' }
77
s.author = { "pNre" => "mail@pnre.co" }
8-
s.source = { :git => "https://github.com/pNre/ExSwift.git", :tag => "0.1.8" }
8+
s.source = { :git => "https://github.com/pNre/ExSwift.git", :tag => "0.1.9" }
99
s.source_files = 'ExSwift/*.{h,swift}'
1010
s.frameworks = 'Foundation'
1111
s.requires_arc = true

ExSwift.xcodeproj/project.pbxproj

+4-7
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
1E48E6211973ED07006FEEC8 /* Double.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E48E61D1973ED07006FEEC8 /* Double.swift */; };
2727
1E48E6231973ED22006FEEC8 /* ExSwiftDoubleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E48E6221973ED22006FEEC8 /* ExSwiftDoubleTests.swift */; };
2828
1E48E6241973ED22006FEEC8 /* ExSwiftDoubleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E48E6221973ED22006FEEC8 /* ExSwiftDoubleTests.swift */; };
29-
1E8F0DA8197ED7B600F2F891 /* XCTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E8F0DA7197ED7B600F2F891 /* XCTestCase.swift */; };
30-
1E8F0DA9197ED7B600F2F891 /* XCTestCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E8F0DA7197ED7B600F2F891 /* XCTestCase.swift */; };
3129
1EA5F68A194387CA00E8A40F /* ExSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EA5F689194387CA00E8A40F /* ExSwiftTests.swift */; };
3230
1EC241FC1946E91B0047109A /* NSArray.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EC241FB1946E91B0047109A /* NSArray.swift */; };
3331
1EC241FE1946E92E0047109A /* ExSwiftNSArrayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EC241FD1946E92E0047109A /* ExSwiftNSArrayTests.swift */; };
@@ -93,7 +91,6 @@
9391
1E11AFB11943225B006BCE48 /* String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
9492
1E48E61D1973ED07006FEEC8 /* Double.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Double.swift; sourceTree = "<group>"; };
9593
1E48E6221973ED22006FEEC8 /* ExSwiftDoubleTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExSwiftDoubleTests.swift; sourceTree = "<group>"; };
96-
1E8F0DA7197ED7B600F2F891 /* XCTestCase.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = XCTestCase.swift; sourceTree = "<group>"; };
9794
1EA5F689194387CA00E8A40F /* ExSwiftTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExSwiftTests.swift; sourceTree = "<group>"; };
9895
1EC241FB1946E91B0047109A /* NSArray.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSArray.swift; sourceTree = "<group>"; };
9996
1EC241FD1946E92E0047109A /* ExSwiftNSArrayTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ExSwiftNSArrayTests.swift; sourceTree = "<group>"; };
@@ -196,7 +193,6 @@
196193
1E11AFA519432236006BCE48 /* ExSwiftStringTests.swift */,
197194
1EA5F689194387CA00E8A40F /* ExSwiftTests.swift */,
198195
1EC241FD1946E92E0047109A /* ExSwiftNSArrayTests.swift */,
199-
1E8F0DA7197ED7B600F2F891 /* XCTestCase.swift */,
200196
1E11AF941943222D006BCE48 /* Supporting Files */,
201197
);
202198
path = ExSwiftTests;
@@ -410,7 +406,6 @@
410406
1E48E6231973ED22006FEEC8 /* ExSwiftDoubleTests.swift in Sources */,
411407
1E11AFA819432236006BCE48 /* ExSwiftFloatTests.swift in Sources */,
412408
1E11AFA719432236006BCE48 /* ExSwiftDictionaryTests.swift in Sources */,
413-
1E8F0DA8197ED7B600F2F891 /* XCTestCase.swift in Sources */,
414409
1E48E61F1973ED07006FEEC8 /* Double.swift in Sources */,
415410
3C0AB97D195C7FBC0009BDA0 /* ExSwiftSequenceTests.swift in Sources */,
416411
2EB34F0C195473AC00A8D2AF /* NSArray.swift in Sources */,
@@ -455,7 +450,6 @@
455450
1E48E6241973ED22006FEEC8 /* ExSwiftDoubleTests.swift in Sources */,
456451
1ED8FC33194EF9E1004F829A /* ExSwiftRangeTests.swift in Sources */,
457452
1ED8FC34194EF9E1004F829A /* ExSwiftStringTests.swift in Sources */,
458-
1E8F0DA9197ED7B600F2F891 /* XCTestCase.swift in Sources */,
459453
1E48E6211973ED07006FEEC8 /* Double.swift in Sources */,
460454
3C0AB97E195C7FC20009BDA0 /* ExSwiftSequenceTests.swift in Sources */,
461455
2EB34F141954744D00A8D2AF /* NSArray.swift in Sources */,
@@ -491,6 +485,7 @@
491485
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
492486
COPY_PHASE_STRIP = NO;
493487
CURRENT_PROJECT_VERSION = 1;
488+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
494489
ENABLE_STRICT_OBJC_MSGSEND = YES;
495490
GCC_C_LANGUAGE_STANDARD = gnu99;
496491
GCC_DYNAMIC_NO_PIC = NO;
@@ -547,7 +542,9 @@
547542
GCC_WARN_UNUSED_VARIABLE = YES;
548543
MACOSX_DEPLOYMENT_TARGET = 10.9;
549544
METAL_ENABLE_DEBUG_INFO = NO;
545+
ONLY_ACTIVE_ARCH = NO;
550546
SDKROOT = macosx;
547+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
551548
VERSIONING_SYSTEM = "apple-generic";
552549
VERSION_INFO_PREFIX = "";
553550
};
@@ -568,7 +565,7 @@
568565
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
569566
PRODUCT_NAME = "$(TARGET_NAME)";
570567
SKIP_INSTALL = YES;
571-
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
568+
SWIFT_OPTIMIZATION_LEVEL = "-O";
572569
};
573570
name = Debug;
574571
};

ExSwift/Array.swift

+17-11
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public extension Array {
112112

113113
:returns: First element of the array if not empty
114114
*/
115-
func first () -> Element? {
115+
@availability(*, unavailable, message="use the 'first' property instead") func first () -> Element? {
116116
return first
117117
}
118118

@@ -121,7 +121,7 @@ public extension Array {
121121

122122
:returns: Last element of the array if not empty
123123
*/
124-
func last () -> Element? {
124+
@availability(*, unavailable, message="use the 'last' property instead") func last () -> Element? {
125125
return last
126126
}
127127

@@ -248,8 +248,10 @@ public extension Array {
248248
var result = [Array]()
249249

250250
// If no step is supplied move n each step.
251-
step = step ?? n
252-
251+
if step == nil {
252+
step = n
253+
}
254+
253255
if step < 1 { step = 1 } // Less than 1 results in an infinite loop.
254256
if n < 1 { n = 0 } // Allow 0 if user wants [[],[],[]] for some reason.
255257
if n > count { return [[]] }
@@ -275,8 +277,10 @@ public extension Array {
275277
var result = [Array]()
276278

277279
// If no step is supplied move n each step.
278-
step = step ?? n
279-
280+
if step == nil {
281+
step = n
282+
}
283+
280284
// Less than 1 results in an infinite loop.
281285
if step < 1 {
282286
step = 1
@@ -320,8 +324,10 @@ public extension Array {
320324
var result = [Array]()
321325

322326
// If no step is supplied move n each step.
323-
step = step ?? n
324-
327+
if step == nil {
328+
step = n
329+
}
330+
325331
if step < 1 { step = 1 } // Less than 1 results in an infinite loop.
326332
if n < 1 { n = 0 } // Allow 0 if user wants [[],[],[]] for some reason.
327333

@@ -731,7 +737,7 @@ public extension Array {
731737
self.reduce with initial value self.first()
732738
*/
733739
func reduce (combine: (Element, Element) -> Element) -> Element? {
734-
if let firstElement = first() {
740+
if let firstElement = first {
735741
return skip(1).reduce(firstElement, combine: combine)
736742
}
737743

@@ -943,8 +949,8 @@ public extension Array {
943949
:returns: Array with the items at the specified indexes
944950
*/
945951
subscript (first: Int, second: Int, rest: Int...) -> Array {
946-
typealias IntsType = (Int...)
947-
return at(unsafeBitCast([first, second] + rest, IntsType.self))
952+
let indexes = [first, second] + rest
953+
return indexes.map { self[$0] }
948954
}
949955

950956
}

ExSwift/ExSwift.swift

+40-35
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,18 @@ public class ExSwift {
2525
*/
2626
public class func after <P, T> (n: Int, function: (P...) -> T) -> ((P...) -> T?) {
2727

28-
typealias ParamsType = (P...)
29-
28+
typealias Function = [P] -> T
29+
3030
var times = n
3131

3232
return {
33-
(params: ParamsType) -> T? in
33+
(params: P...) -> T? in
3434

35+
// Workaround for the now illegal (T...) type.
36+
let adaptedFunction = unsafeBitCast(function, Function.self)
37+
3538
if times-- <= 0 {
36-
return function(unsafeBitCast(params, ParamsType.self))
39+
return adaptedFunction(params)
3740
}
3841

3942
return nil
@@ -67,17 +70,18 @@ public class ExSwift {
6770
*/
6871
public class func once <P, T> (function: (P...) -> T) -> ((P...) -> T) {
6972

70-
typealias ParamsType = (P...)
71-
73+
typealias Function = [P] -> T
74+
7275
var returnValue: T? = nil
7376

74-
return { (params: ParamsType) -> T in
77+
return { (params: P...) -> T in
7578

7679
if returnValue != nil {
7780
return returnValue!
7881
}
7982

80-
returnValue = function(unsafeBitCast(params, ParamsType.self))
83+
let adaptedFunction = unsafeBitCast(function, Function.self)
84+
returnValue = adaptedFunction(params)
8185

8286
return returnValue!
8387

@@ -110,14 +114,12 @@ public class ExSwift {
110114
:returns: Wrapper function
111115
*/
112116
public class func partial <P, T> (function: (P...) -> T, _ parameters: P...) -> ((P...) -> T) {
113-
114-
typealias ParamsType = (P...)
115-
116-
return { (params: ParamsType) -> T in
117-
118-
return function(unsafeBitCast(parameters + params, ParamsType.self))
117+
typealias Function = [P] -> T
118+
119+
return { (params: P...) -> T in
120+
let adaptedFunction = unsafeBitCast(function, Function.self)
121+
return adaptedFunction(parameters + params)
119122
}
120-
121123
}
122124

123125
/**
@@ -129,13 +131,12 @@ public class ExSwift {
129131
:returns: Wrapper function
130132
*/
131133
public class func bind <P, T> (function: (P...) -> T, _ parameters: P...) -> (Void -> T) {
132-
133-
typealias ParamsType = (P...)
134-
134+
typealias Function = [P] -> T
135+
135136
return { Void -> T in
136-
return function(unsafeBitCast(parameters, ParamsType.self))
137+
let adaptedFunction = unsafeBitCast(function, Function.self)
138+
return adaptedFunction(parameters)
137139
}
138-
139140
}
140141

141142
/**
@@ -146,20 +147,23 @@ public class ExSwift {
146147
:returns: Wrapper function
147148
*/
148149
public class func cached <P: Hashable, R> (function: (P...) -> R, hash: ((P...) -> P)) -> ((P...) -> R) {
149-
typealias ParamsType = (P...)
150+
typealias Function = [P] -> R
151+
typealias Hash = [P] -> P
150152

151153
var cache = [P:R]()
152154

153-
return { (params: ParamsType) -> R in
155+
return { (params: P...) -> R in
156+
157+
let adaptedFunction = unsafeBitCast(function, Function.self)
158+
let adaptedHash = unsafeBitCast(hash, Hash.self)
154159

155-
let paramsList = unsafeBitCast(params, ParamsType.self)
156-
let key = hash(paramsList)
160+
let key = adaptedHash(params)
157161

158162
if let cachedValue = cache[key] {
159163
return cachedValue
160164
}
161165

162-
cache[key] = function(paramsList)
166+
cache[key] = adaptedFunction(params)
163167

164168
return cache[key]!
165169
}
@@ -184,14 +188,14 @@ public class ExSwift {
184188
*/
185189
internal class func regex (pattern: String, ignoreCase: Bool = false) -> NSRegularExpression? {
186190

187-
var options: NSRegularExpressionOptions = NSRegularExpressionOptions.DotMatchesLineSeparators
191+
var options = NSRegularExpressionOptions.DotMatchesLineSeparators.toRaw()
188192

189193
if ignoreCase {
190-
options = NSRegularExpressionOptions.CaseInsensitive | options
194+
options = NSRegularExpressionOptions.CaseInsensitive.toRaw() | options
191195
}
192196

193197
var error: NSError? = nil
194-
let regex = NSRegularExpression.regularExpressionWithPattern(pattern, options: options, error: &error)
198+
let regex = NSRegularExpression.regularExpressionWithPattern(pattern, options: NSRegularExpressionOptions.fromRaw(options)!, error: &error)
195199

196200
return (error == nil) ? regex : nil
197201

@@ -215,14 +219,18 @@ extension ExSwift {
215219
let reflection = reflect(object)
216220

217221
// object has an Objective-C type
218-
if reflection.disposition == .ObjCObject {
222+
if let obj = object as? T {
223+
// object has type T
224+
result.append(obj)
225+
} else if reflection.disposition == .ObjCObject {
219226

227+
var bridgedValue: T!?
228+
220229
// If it is an NSArray, flattening will produce the expected result
221230
if let array = object as? NSArray {
222231
result += array.flatten()
223-
} else if let bridgedValue = ImplicitlyUnwrappedOptional<T>._bridgeFromObjectiveCConditional(reflection.value as NSObject) {
224-
// the object type can be converted to the Swift native type T
225-
result.append(bridgedValue)
232+
} else if let bridged = reflection.value as? T {
233+
result.append(bridged)
226234
}
227235
} else if reflection.disposition == .IndexContainer {
228236
// object is a native Swift array
@@ -234,9 +242,6 @@ extension ExSwift {
234242
result += Ex.bridgeObjCObject(ref.value)
235243
}
236244

237-
} else if let obj = object as? T {
238-
// object has type T
239-
result.append(obj)
240245
}
241246

242247
return result

ExSwift/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.1.8</string>
18+
<string>0.1.9</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

ExSwift/NSArray.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public extension NSArray {
1515

1616
:returns: Array of Swift objects
1717
*/
18-
func cast <OutType> () -> Array<OutType> {
19-
var result = Array<OutType>()
18+
func cast <OutType> () -> [OutType] {
19+
var result = [OutType]()
2020

2121
for item : AnyObject in self {
2222
result += Ex.bridgeObjCObject(item) as [OutType]

0 commit comments

Comments
 (0)