Many of the types are bridged to the Swift type like as (e.g., NSString being bridged to String).
Other Objective-C types are bridged to Swift are as follows :
New version of SDK is 4.16.x(Swift) and Graph API Version is 2.8.
With the Graph API 2.6 Facebook has given support to fetch (read only) the Reactions on Timeline Posts.
We can get the Facebook post reactions via graph API : /{post-id}/reactions. We have to pass parameters like fields and summary as described in getReactions function. Note : Here I am writing sample for only first post.
I was just going through the Swift document and I found that Swift allow to overload the operator just like as C++ Language. Objective-C doesn’t allow to overload the operator.
As swift document we can also say “Operator Functions”.
Let’s Overload ^ (XOR Operator) to make Power of the value
Function Prototype :
Declare function prototype with left hand side value and right and side value.
Swift
1
2
func^(lhs:Int,rhs:Int)->Int{
}
Operations in the function :
To make the power of the value we have to apply following operations
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
EasyAnimation A Swift library to take the power of UIView.animateWithDuration(_:, animations:…) to a whole new level – layers, springs, chain-able animations and mixing view and layer animations together!
In Objective-C we are using a header file to create constant variables like as
[code lang=”obj-c”]
// Objective-C
#define APP_ALERT_TITLE "Objective-C Constant"
[/code]
Swift has new syntax to define the constant (#define)
[code lang=”obj-c”]
// Swift
let APP_ALERT_TITLE = "Swift Constants"
[/code]
Lets try
Create a swift file with the constants
[code lang=”obj-c”]
import Foundation
class Constants {
// MARK: List of Constants
static let APP_ALERT_TITLE = "Swift Constants"
static let SAMPLE_MESSAGE = "The alert is working !!"
}
[/code] Note : Here the MARK statement is also changed.
[code lang=”obj-c”]
// Objective-C
#pragma mark –
#pragma mark List of Constants
[/code]
[code lang=”obj-c”]
// Swift
// MARK: List of Constants
[/code]
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.