Bye Bye to NS from Swift!!

Logo NeXTSTEP
Logo NeXTSTEP

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 :

Objective-C Swift
NSString String
NSArray Array
NSDictionary Dictionary
NSData Data
NSError Error (Added Swift 3 – Xcode 8 Beta 4)
NSNotificationCenter NotificationCenter

And more…
Bye Bye to NS from Swift!!
Happy Coding πŸ™‚

iOS 10 New Frameworks

iOS10

  • CallKit
    The CallKit framework (CallKit.framework) lets VoIP apps integrate with the iPhone UI and give users a great experience. Use this framework to let users view and answer incoming VoIP calls on the lock screen and manage contacts from VoIP calls in the Phone app’s Favorites and Recents views.
  • Intents
    The Intents framework (Intents.framework) supports the handling of SiriKit interactions.
  • IntentsUI
    The Intents UI framework (IntentsUI.framework) supports the creation of an Intents UI extension, which is an optional app extension that displays custom content in the Siri or Maps interfaces.
  • Messages
    To develop an iMessage app, you use the APIs in the Messages framework (Messages.framework) and To create app extensions that interact with the Messages app, allowing users to send text, stickers, media files, and interactive messages.
  • Speech
    Using the APIs in the Speech framework (Speech.framework), you can perform speech transcription of both real-time and recorded audio.
  • UserNotifications
    User Notifications framework (UserNotifications.framework), which supports the delivery and handling of local and remote notifications.
  • UserNotificationsUI
    User Notifications UI framework (UserNotificationsUI.framework) lets you customize the appearance of local and remote notifications when they appear on the user’s device.
  • VideoSubscriberAccount
    Video Subscriber Account framework (VideoSubscriberAccount.framework) to help apps that support authenticated streaming or authenticated video on demand (also known as TV Everywhere) authenticate with their cable or satellite TV provider.

References :

Best Tweets of iOS 10 & Swift 3 Updates

Announcements from Apple’s WWDC 2016 keynote

Apple Special Event. June 13, 2016.

WWDC16
WWDC16

At WWDC lots of major announcements. iOS 10 is biggest release yet, with incredible features in Messages and an all-new design for Maps, Photos, and Apple Music. With macOS Sierra, Siri makes its debut on your desktop and Apple Pay comes to the web. The latest watchOS offers easier navigation and a big boost in performance. And the updated tvOS brings expanded Siri searches.

  • watchOS 3
  • tvOS
  • macOS Sierra
  • Siri for Mac
  • Apple Pay in Web
  • iOS 10
  • Swift Playgrounds – iPad

Now, Go with flow of technology, let’s learn something new… πŸ˜‰

Get Reactions from Timeline Post via Facebook Graph API – Swift – iOS

Facebook Reactions
Facebook Reactions

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.

Post is updated for iOS 10 and Swift 3

API documentation is available here.

Let’s learn how to get reactions from the post

Install pods

Login with Facebook

I have already written a tutorial on Facebook Login.

Get Facebook Posts via Graph API

We can get the Facebook post via graph API : /me/posts for that we have to add user_posts permission with login.

Get Reactions from one of the Post

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.

Response should be like

Type of reactions : NONE, LIKE, LOVE, WOW, HAHA, SAD, ANGRY

#Like #Share #React πŸ™‚ πŸ˜› πŸ˜€
Happy coding πŸ™‚

Use of Operator Overloading with Swift

apple_swift_logo

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.

Operations in the function :
To make the power of the value we have to apply following operations

Let’s try to use with the operator :

Happy Coding πŸ™‚

Swift 2.2 Warnings and It's Solutions – Xcode 7.3

apple_swift_logo

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:

  1. ‘var’ parameters are deprecated and will be removed in Swift 3
  2. Warning Function Var
    Warning Function Var

    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.

  3. Use of string literal for Objective-C selectors is deprecated; use ‘#selector’ instead
  4. Warning Selector
    Warning Selector

    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.

  5. ‘++’ is deprecated: it will be removed in Swift 3
  6. Warning ++
    Warning ++

    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.

  7. C-style for statement is deprecated and will be removed in a future version of Swift
  8. Warning For Statement
    Warning For Statement

    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]

  9. __FILE__ is deprecated and will be removed in Swift 3, please use #file
  10. Warning __FILE__
    Warning __FILE__

    Warning with:
    [code language=”obj-c”]
    __FILE__
    [/code]
    Solution:
    [code language=”obj-c”]
    #file
    [/code]

More swift tutorials/articles are available here.
Happy Coding πŸ™‚

Swift Resources #3

Swift Resources
Swift Resources

Swift Useful Resources:

Posted by @NatashaTheRobot in Issue No. 80
If I got time then I will try to post the Swift/Objective-C useful resources everyday.
Happy Coding πŸ™‚

Let Us Loop You Out Again – Apple Event Announcements

Apple’s ‘Let Us Loop You In’ On March 21, 2016 a special event by Apple.
Let Us Loop You In

for loopYou in letUS {
break
}

Announcements

  • Apple introduces Liam.
  • Apple announces CareKit.
  • Apple Watch sport and leather bands in new colors for spring.
  • Apple introduces the iPhone SE.
  • iOS 9.3 is available as a free update for everyone beginning today.
  • Apple introduces 9.7-inch iPad Pro.

Read more

Swift Resources #2 – for Animation

Swift Resources
Swift Resources

Swift Useful Animation Resources:

  • Spring A library to simplify iOS animations in Swift.
  • Animo Bring life to CALayers with SpriteKit-like animation builders
  • Advance A powerful animation framework for iOS and OS X.
  • CKWaveCollectionViewTransition Cool wave like transition between two or more UICollectionView
  • 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!
  • Cheetah Easy animation library on iOS with Swift2

If I got time then I will try to post the Swift/Objective-C useful resources everyday.
Happy Coding πŸ™‚