Skip to content

Commit 97b208e

Browse files
committed
Update to Swift 2.1.
1 parent dbd5f23 commit 97b208e

File tree

7 files changed

+32
-216
lines changed

7 files changed

+32
-216
lines changed

LTBouncyPlaceholder/UITextField+LTBouncyPlaceholder.swift

+13-13
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class LTBouncyTextField : UITextField {
2525
*/
2626
public var alwaysBouncePlaceholder: Bool {
2727
get {
28-
var _alwaysBouncePlaceholderObject : AnyObject?
28+
let _alwaysBouncePlaceholderObject : AnyObject?
2929
= objc_getAssociatedObject(self, &kAlwaysBouncePlaceholderPointer)
3030
if let _alwaysBouncePlaceholder = _alwaysBouncePlaceholderObject?.boolValue {
3131
return _alwaysBouncePlaceholder
@@ -37,13 +37,13 @@ public class LTBouncyTextField : UITextField {
3737
objc_setAssociatedObject(self,
3838
&kAlwaysBouncePlaceholderPointer,
3939
newValue,
40-
objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
40+
objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
4141
}
4242
}
4343

4444
public var abbreviatedPlaceholder: String? {
4545
get {
46-
var _abbreviatedPlaceholderObject: AnyObject? = objc_getAssociatedObject(self, &kAbbreviatedPlaceholderPointer)
46+
let _abbreviatedPlaceholderObject: AnyObject? = objc_getAssociatedObject(self, &kAbbreviatedPlaceholderPointer)
4747
if let _abbreviatedPlaceholder: AnyObject = _abbreviatedPlaceholderObject {
4848
return _abbreviatedPlaceholder as? String
4949
}
@@ -54,44 +54,44 @@ public class LTBouncyTextField : UITextField {
5454
objc_setAssociatedObject(self,
5555
&kAbbreviatedPlaceholderPointer,
5656
newValue,
57-
objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
57+
objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
5858
}
5959
}
6060

6161
private var lt_placeholderLabel: UILabel {
6262
get {
63-
var _placeholderLabelObject: AnyObject? = objc_getAssociatedObject(self, &kPlaceholderLabelPointer)
63+
let _placeholderLabelObject: AnyObject? = objc_getAssociatedObject(self, &kPlaceholderLabelPointer)
6464
if let _placeholderLabel : AnyObject = _placeholderLabelObject {
6565
return _placeholderLabel as! UILabel
6666
}
67-
var _placeholderLabel = UILabel(frame: placeholderRectForBounds(bounds))
67+
let _placeholderLabel = UILabel(frame: placeholderRectForBounds(bounds))
6868
_placeholderLabel.font = font
6969
_placeholderLabel.text = placeholder
7070
_placeholderLabel.textColor = .lightGrayColor()
7171
addSubview(_placeholderLabel)
7272
objc_setAssociatedObject(self,
7373
&kPlaceholderLabelPointer,
7474
_placeholderLabel,
75-
objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
75+
objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
7676
return _placeholderLabel
7777
}
7878
}
7979

8080
private var lt_rightPlaceholderLabel: UILabel {
8181
get {
82-
var _rightPlaceholderLabelObject: AnyObject? = objc_getAssociatedObject(self, &kRightPlaceholderLabelPointer)
82+
let _rightPlaceholderLabelObject: AnyObject? = objc_getAssociatedObject(self, &kRightPlaceholderLabelPointer)
8383
if let _rightPlaceholderLabel: AnyObject = _rightPlaceholderLabelObject {
8484
return _rightPlaceholderLabel as! UILabel
8585
}
86-
var _rightPlaceholderLabel = UILabel(frame: placeholderRectForBounds(bounds))
86+
let _rightPlaceholderLabel = UILabel(frame: placeholderRectForBounds(bounds))
8787
_rightPlaceholderLabel.font = font
8888
_rightPlaceholderLabel.textColor = .lightGrayColor()
8989
_rightPlaceholderLabel.layer.opacity = 0.0
9090
addSubview(_rightPlaceholderLabel)
9191
objc_setAssociatedObject(self,
9292
&kRightPlaceholderLabelPointer,
9393
_rightPlaceholderLabel,
94-
objc_AssociationPolicy(OBJC_ASSOCIATION_RETAIN_NONATOMIC))
94+
objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
9595
return _rightPlaceholderLabel
9696
}
9797
}
@@ -156,14 +156,14 @@ public class LTBouncyTextField : UITextField {
156156

157157
if let _rightPlaceholder = rightPlaceholder {
158158
let attributes = [NSFontAttributeName: lt_rightPlaceholderLabel.font]
159-
var abbrSize = _rightPlaceholder.sizeWithAttributes(attributes)
159+
let abbrSize = _rightPlaceholder.sizeWithAttributes(attributes)
160160
return Float(abbrSize.width)
161161
}
162162
return 0
163163
}
164164
}
165165

166-
private func _bounceKeyframes(#toRight: Bool) -> NSArray {
166+
private func _bounceKeyframes(toRight toRight: Bool) -> NSArray {
167167
let steps = 100
168168
var values = [Double]()
169169
var value: Double
@@ -180,7 +180,7 @@ public class LTBouncyTextField : UITextField {
180180
return values
181181
}
182182

183-
private func _animatePlaceholder (#toRight: Bool) {
183+
private func _animatePlaceholder (toRight toRight: Bool) {
184184
if let abbrPlaceholder = abbreviatedPlaceholder {
185185
if (toRight) {
186186
if lt_rightPlaceholderLabel.layer.presentationLayer().opacity > 0 {

LTBouncyPlaceholderDemo.xcodeproj/project.pbxproj

+2-131
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,15 @@
99
/* Begin PBXBuildFile section */
1010
D7900DD0194591E500F9A51F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7900DCF194591E500F9A51F /* AppDelegate.swift */; };
1111
D7900DD2194591E500F9A51F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D7900DD1194591E500F9A51F /* Images.xcassets */; };
12-
D7900DDE194591E500F9A51F /* LTBouncyPlaceholderDemoTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7900DDD194591E500F9A51F /* LTBouncyPlaceholderDemoTests.swift */; };
1312
D7900DE81945920000F9A51F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D7900DE71945920000F9A51F /* Main.storyboard */; };
1413
D7900DEB194592A800F9A51F /* UITextField+LTBouncyPlaceholder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7900DEA194592A800F9A51F /* UITextField+LTBouncyPlaceholder.swift */; };
1514
/* End PBXBuildFile section */
1615

17-
/* Begin PBXContainerItemProxy section */
18-
D7900DD8194591E500F9A51F /* PBXContainerItemProxy */ = {
19-
isa = PBXContainerItemProxy;
20-
containerPortal = D7900DC2194591E500F9A51F /* Project object */;
21-
proxyType = 1;
22-
remoteGlobalIDString = D7900DC9194591E500F9A51F;
23-
remoteInfo = LTBouncyPlaceholderDemo;
24-
};
25-
/* End PBXContainerItemProxy section */
26-
2716
/* Begin PBXFileReference section */
2817
D7900DCA194591E500F9A51F /* LTBouncyPlaceholderDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LTBouncyPlaceholderDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
2918
D7900DCE194591E500F9A51F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
3019
D7900DCF194591E500F9A51F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
3120
D7900DD1194591E500F9A51F /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
32-
D7900DD7194591E500F9A51F /* LTBouncyPlaceholderDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LTBouncyPlaceholderDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
33-
D7900DDC194591E500F9A51F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
34-
D7900DDD194591E500F9A51F /* LTBouncyPlaceholderDemoTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LTBouncyPlaceholderDemoTests.swift; sourceTree = "<group>"; };
3521
D7900DE71945920000F9A51F /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
3622
D7900DEA194592A800F9A51F /* UITextField+LTBouncyPlaceholder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UITextField+LTBouncyPlaceholder.swift"; sourceTree = "<group>"; };
3723
/* End PBXFileReference section */
@@ -44,13 +30,6 @@
4430
);
4531
runOnlyForDeploymentPostprocessing = 0;
4632
};
47-
D7900DD4194591E500F9A51F /* Frameworks */ = {
48-
isa = PBXFrameworksBuildPhase;
49-
buildActionMask = 2147483647;
50-
files = (
51-
);
52-
runOnlyForDeploymentPostprocessing = 0;
53-
};
5433
/* End PBXFrameworksBuildPhase section */
5534

5635
/* Begin PBXGroup section */
@@ -59,7 +38,6 @@
5938
children = (
6039
D7900DE91945928400F9A51F /* LTBouncyPlaceholder */,
6140
D7900DCC194591E500F9A51F /* LTBouncyPlaceholderDemo */,
62-
D7900DDA194591E500F9A51F /* LTBouncyPlaceholderDemoTests */,
6341
D7900DCB194591E500F9A51F /* Products */,
6442
);
6543
sourceTree = "<group>";
@@ -68,7 +46,6 @@
6846
isa = PBXGroup;
6947
children = (
7048
D7900DCA194591E500F9A51F /* LTBouncyPlaceholderDemo.app */,
71-
D7900DD7194591E500F9A51F /* LTBouncyPlaceholderDemoTests.xctest */,
7249
);
7350
name = Products;
7451
sourceTree = "<group>";
@@ -92,23 +69,6 @@
9269
name = "Supporting Files";
9370
sourceTree = "<group>";
9471
};
95-
D7900DDA194591E500F9A51F /* LTBouncyPlaceholderDemoTests */ = {
96-
isa = PBXGroup;
97-
children = (
98-
D7900DDD194591E500F9A51F /* LTBouncyPlaceholderDemoTests.swift */,
99-
D7900DDB194591E500F9A51F /* Supporting Files */,
100-
);
101-
path = LTBouncyPlaceholderDemoTests;
102-
sourceTree = "<group>";
103-
};
104-
D7900DDB194591E500F9A51F /* Supporting Files */ = {
105-
isa = PBXGroup;
106-
children = (
107-
D7900DDC194591E500F9A51F /* Info.plist */,
108-
);
109-
name = "Supporting Files";
110-
sourceTree = "<group>";
111-
};
11272
D7900DE91945928400F9A51F /* LTBouncyPlaceholder */ = {
11373
isa = PBXGroup;
11474
children = (
@@ -137,40 +97,20 @@
13797
productReference = D7900DCA194591E500F9A51F /* LTBouncyPlaceholderDemo.app */;
13898
productType = "com.apple.product-type.application";
13999
};
140-
D7900DD6194591E500F9A51F /* LTBouncyPlaceholderDemoTests */ = {
141-
isa = PBXNativeTarget;
142-
buildConfigurationList = D7900DE4194591E500F9A51F /* Build configuration list for PBXNativeTarget "LTBouncyPlaceholderDemoTests" */;
143-
buildPhases = (
144-
D7900DD3194591E500F9A51F /* Sources */,
145-
D7900DD4194591E500F9A51F /* Frameworks */,
146-
D7900DD5194591E500F9A51F /* Resources */,
147-
);
148-
buildRules = (
149-
);
150-
dependencies = (
151-
D7900DD9194591E500F9A51F /* PBXTargetDependency */,
152-
);
153-
name = LTBouncyPlaceholderDemoTests;
154-
productName = LTBouncyPlaceholderDemoTests;
155-
productReference = D7900DD7194591E500F9A51F /* LTBouncyPlaceholderDemoTests.xctest */;
156-
productType = "com.apple.product-type.bundle.unit-test";
157-
};
158100
/* End PBXNativeTarget section */
159101

160102
/* Begin PBXProject section */
161103
D7900DC2194591E500F9A51F /* Project object */ = {
162104
isa = PBXProject;
163105
attributes = {
106+
LastSwiftMigration = 0720;
107+
LastSwiftUpdateCheck = 0720;
164108
LastUpgradeCheck = 0600;
165109
ORGANIZATIONNAME = LexTang.com;
166110
TargetAttributes = {
167111
D7900DC9194591E500F9A51F = {
168112
CreatedOnToolsVersion = 6.0;
169113
};
170-
D7900DD6194591E500F9A51F = {
171-
CreatedOnToolsVersion = 6.0;
172-
TestTargetID = D7900DC9194591E500F9A51F;
173-
};
174114
};
175115
};
176116
buildConfigurationList = D7900DC5194591E500F9A51F /* Build configuration list for PBXProject "LTBouncyPlaceholderDemo" */;
@@ -186,7 +126,6 @@
186126
projectRoot = "";
187127
targets = (
188128
D7900DC9194591E500F9A51F /* LTBouncyPlaceholderDemo */,
189-
D7900DD6194591E500F9A51F /* LTBouncyPlaceholderDemoTests */,
190129
);
191130
};
192131
/* End PBXProject section */
@@ -201,13 +140,6 @@
201140
);
202141
runOnlyForDeploymentPostprocessing = 0;
203142
};
204-
D7900DD5194591E500F9A51F /* Resources */ = {
205-
isa = PBXResourcesBuildPhase;
206-
buildActionMask = 2147483647;
207-
files = (
208-
);
209-
runOnlyForDeploymentPostprocessing = 0;
210-
};
211143
/* End PBXResourcesBuildPhase section */
212144

213145
/* Begin PBXSourcesBuildPhase section */
@@ -220,24 +152,8 @@
220152
);
221153
runOnlyForDeploymentPostprocessing = 0;
222154
};
223-
D7900DD3194591E500F9A51F /* Sources */ = {
224-
isa = PBXSourcesBuildPhase;
225-
buildActionMask = 2147483647;
226-
files = (
227-
D7900DDE194591E500F9A51F /* LTBouncyPlaceholderDemoTests.swift in Sources */,
228-
);
229-
runOnlyForDeploymentPostprocessing = 0;
230-
};
231155
/* End PBXSourcesBuildPhase section */
232156

233-
/* Begin PBXTargetDependency section */
234-
D7900DD9194591E500F9A51F /* PBXTargetDependency */ = {
235-
isa = PBXTargetDependency;
236-
target = D7900DC9194591E500F9A51F /* LTBouncyPlaceholderDemo */;
237-
targetProxy = D7900DD8194591E500F9A51F /* PBXContainerItemProxy */;
238-
};
239-
/* End PBXTargetDependency section */
240-
241157
/* Begin XCBuildConfiguration section */
242158
D7900DDF194591E500F9A51F /* Debug */ = {
243159
isa = XCBuildConfiguration;
@@ -338,42 +254,6 @@
338254
};
339255
name = Release;
340256
};
341-
D7900DE5194591E500F9A51F /* Debug */ = {
342-
isa = XCBuildConfiguration;
343-
buildSettings = {
344-
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/LTBouncyPlaceholderDemo.app/LTBouncyPlaceholderDemo";
345-
FRAMEWORK_SEARCH_PATHS = (
346-
"$(SDKROOT)/Developer/Library/Frameworks",
347-
"$(inherited)",
348-
);
349-
GCC_PREPROCESSOR_DEFINITIONS = (
350-
"DEBUG=1",
351-
"$(inherited)",
352-
);
353-
INFOPLIST_FILE = LTBouncyPlaceholderDemoTests/Info.plist;
354-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
355-
METAL_ENABLE_DEBUG_INFO = YES;
356-
PRODUCT_NAME = "$(TARGET_NAME)";
357-
TEST_HOST = "$(BUNDLE_LOADER)";
358-
};
359-
name = Debug;
360-
};
361-
D7900DE6194591E500F9A51F /* Release */ = {
362-
isa = XCBuildConfiguration;
363-
buildSettings = {
364-
BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/LTBouncyPlaceholderDemo.app/LTBouncyPlaceholderDemo";
365-
FRAMEWORK_SEARCH_PATHS = (
366-
"$(SDKROOT)/Developer/Library/Frameworks",
367-
"$(inherited)",
368-
);
369-
INFOPLIST_FILE = LTBouncyPlaceholderDemoTests/Info.plist;
370-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
371-
METAL_ENABLE_DEBUG_INFO = NO;
372-
PRODUCT_NAME = "$(TARGET_NAME)";
373-
TEST_HOST = "$(BUNDLE_LOADER)";
374-
};
375-
name = Release;
376-
};
377257
/* End XCBuildConfiguration section */
378258

379259
/* Begin XCConfigurationList section */
@@ -395,15 +275,6 @@
395275
defaultConfigurationIsVisible = 0;
396276
defaultConfigurationName = Release;
397277
};
398-
D7900DE4194591E500F9A51F /* Build configuration list for PBXNativeTarget "LTBouncyPlaceholderDemoTests" */ = {
399-
isa = XCConfigurationList;
400-
buildConfigurations = (
401-
D7900DE5194591E500F9A51F /* Debug */,
402-
D7900DE6194591E500F9A51F /* Release */,
403-
);
404-
defaultConfigurationIsVisible = 0;
405-
defaultConfigurationName = Release;
406-
};
407278
/* End XCConfigurationList section */
408279
};
409280
rootObject = D7900DC2194591E500F9A51F /* Project object */;

0 commit comments

Comments
 (0)