Xcode 7.3 came with Swift 2.2 Version. I just updated to Xcode 7.3 and found following warnings because of Swift version change.
List of warnings with it’s solution:
‘var’ parameters are deprecated and will be removed in Swift 3
Warning with:
[code language=”obj-c”]
func functionTest(var param:String) {
print(param)
}
[/code]
Solution:
[code language=”obj-c”]
func functionTest(param:String) {
print(param)
}
[/code]
If you want to update that variable inside the function then you have to create copy of that variable to do operations on that.
Use of string literal for Objective-C selectors is deprecated; use ‘#selector’ instead
Warning with:
[code language=”obj-c”]
btn.addTarget(self, action: "functionName", forControlEvents: UIControlEvents.TouchUpInside)
[/code]
OR
[code language=”obj-c”]
btn.addTarget(self, action: Selector("functionName"), forControlEvents: UIControlEvents.TouchUpInside)
[/code]
Solution:
[code language=”obj-c”]
btn.addTarget(self, action: #selector(ViewController.functionName), forControlEvents: UIControlEvents.TouchUpInside)
[/code]
Apple Documentation : Added information about the #selector syntax for Objective-C selectors to the Selector Expression section.
‘++’ is deprecated: it will be removed in Swift 3
Warning with:
[code language=”obj-c”]
var i = 0
for str in arrStr {
print(str)
i++
}
[/code]
Solution:
[code language=”obj-c”]
var i = 0
for str in arrStr {
print(str)
i += 1
}
[/code]
Apple Documentation : Removed discussion of C-style for loops, the ++ prefix and postfix operators, and the — prefix and postfix operators.
C-style for statement is deprecated and will be removed in a future version of Swift
Warning with:
[code language=”obj-c”]
for var i=0; i<arrStr.count; i += 1 {
print(arrStr[i])
}
[/code]
Solution:
[code language=”obj-c”]
for i in 0 ..< arrStr.count {
print(arrStr[i])
}
[/code]
__FILE__ is deprecated and will be removed in Swift 3, please use #file
3. Now we will create a Base UIViewController to use anywhere in the project which control the delegate of menu.
First we will create this 3 lines Drawer Icon via Code
To open a view controller by identifier :
Set the Restoration Identifier and Storyboard Identifier. If current view is open then we will not open it once again for that we have to check via Restoration Identifier.
By giving you a simple example that we can not change the corner radius from the design view. We have to change it run time. If you want to make possible it with design time then you can use the @IBDesignable and @IBInspectable.
So, We are taking an example as IBButtonExtender for this the functionality
Border Color
Border Width
Corner Radius
Create an Custom Class for UIButton with @IBDesignable
Swift
1
2
3
@IBDesignable
classButtonExtender: UIButton{
}
Create an @IBInspectable for Inspect the element. the Border Color property will be added to the list in the right panel when you create button with this class.
Presenting the ButtonExtender for Border Color, Border Width and Corner Radius function with the @IBDesignable and @IBInspectable in the Swift Language.
By making some corner radius and colors, You will get neat and clean output.
Github
Find IBButtonExtender on github 🙂
Check other articles on Swift Language.
All suggestions are acceptable. Put it in the comments!
Happy Coding 🙂