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 🙂

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 🙂

Swift Resources #1

Swift Resources
Swift Resources

Swift Useful Resources:

  • FolioReaderKit FolioReaderKit is an ePub reader and parser framework for iOS written in Swift.
  • KZLinkedConsole Clickable links in your Xcode console, so you never wonder which class logged the message.
  • Chatto A lightweight framework to build chat applications, made in Swift.
  • PFColorHash Generate color based on the given string.
  • SwiftCharts Easy to use and highly customizable charts library for iOS.

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

How to create a wrapper for Alamofire and SwiftyJSON? Swift – iOS

This blogpost updated with Swift 3 – Xcode 8 – iOS 10 – Alamofire 4.0

AFWrapper
AFWrapper

I have posted a basic tutorial about Alamofire and SwiftyJSON How to use Alamofire and SwiftyJSON with Swift?
And some day before we have learned about Use of Blocks(Closures) or Completion Handlers with Function in Swift – iOS
Let’s combine both the topics to make a WRAPPER of Alamofire and SwiftyJSON.

Read more

Use of Blocks(Closures) or Completion Handlers with Function in Swift – iOS

Blocks in Objective-C

In Objective-C we are using the blocks(completion handlers) with functions as follows :

[code language=”obj-c”]
– (void)yourFunctionName:(NSString *)yourString withCompletionHandler:(void (^)(NSString *yourResult))block;
[/code]

Closures in Swift

Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures in Swift are similar to blocks in C and Objective-C and to lambdas in other programming languages.

Syntax with Function

[code language=”obj-c”]
func yourFunctionName(parameter:Type, … , withCompletionHandler:(result:Type) -> Void)
[/code]
For more closure syntax : goshdarnclosuresyntax.com

Example

Function Definition:
[code language=”obj-c”]
func closureReturn(isTest:Bool, withCompletionHandler:(result:String) -> Void) {
if(isTest){
withCompletionHandler(result: "Yes")
}
else{
withCompletionHandler(result: "No")
}
}
[/code]
Calling Function:
[code language=”obj-c”]
closureReturn(true) { (result) -> Void in
print(result)
}
[/code]
Output should be respective to value true/false.


In next post I will write a tutorial on a wrapper class for Alamofire with use of SwiftyJSON by using closures.

It will be related to this post How to use Alamofire and SwiftyJSON with Swift? – Swift 2 – iOS 9 – Xcode 7

Happy Coding 🙂

Work with Core Data in Swift Language

Lets take a brief idea about how to use core data with swift language.

Create a new project by check on Use Core Data.

Core Data Project Setting
Core Data Project Setting

It will create the basic methods of core data in to the AppDelegate.swift

There is core data model called {YOUR-PROJECT.xcdatamodeld} will be there with the project.

It will be look like as follows :

Core Data Model
Core Data Model

Read more

Use of constant (#define) in Swift Language – iOS

Swift Constant Test
Swift Constant Test

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]

Read more

How to use Alamofire and SwiftyJSON with Swift? – Swift 3 – iOS 10 – Xcode 8

Swift JSON
Swift JSON

Alamofire is an HTTP networking library written in Swift.
SwiftyJSON makes it easy to deal with JSON data in Swift.

Read more

Create your own Slider menu (Drawer) in Swift

This article is updated with Swift 4 – Xcode 9 – iOS 11

Why to use a library everytime?

Slider Menu (Drawer)
Slider Menu (Drawer)

Let’s create our own Slide Menu (Drawer) in Swift 4.
1. Create New Project in Xcode 9 with Swift Language
2. Design the Menu in UIViewController
Menu UIViewController
Menu UIViewController

Declaration of Variables and Protocols (Delegate) :

Following method is for updating the Items in the Menu :

Following method is for click event and animation :


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
Preview_Slider_Drawer_ICon

Delegate (Protocol) method call :

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.

4. Now We will assign this drawer to any of the UIViewController
We have to use only one method to add drawer (slide menu) self.addSlideMenuButton()


Source Code is available at the Github AKSwiftSlideMenu

GitHub AKSwiftSlideMenu Releases
GitHub AKSwiftSlideMenu Releases

You can download for versions of Swift 2, Swift 3 or Swift 4. From Releases Tab at GitHub AKSwiftSlideMenu.

I have uploaded a video for easy way to integrate AKSwiftSlideMenu in your project :


Check other blog posts about Swift

Happy Coding 🙂