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!
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.
Parse Parse is Mobile Backend as a Service (MBaaS)
They have written :
We have a difficult announcement to make. Beginning today we’re winding down the Parse service, and Parse will be fully retired after a year-long period ending on January 28, 2017. We’re proud that we’ve been able to help so many of you build great mobile apps, but we need to focus our resources elsewhere.
I am posting this article because many users are facing this issue like “This certificate has an invalid issuer”
This certificate has an invalid issuer
As apple have written :
The Apple Worldwide Developer Relations Certification Intermediate Certificate expires soon and we’ve issued a renewed certificate that must be included when signing all new Apple Wallet Passes, push packages for Safari Push Notifications, and Safari Extensions starting February 14, 2016.
Open KeyChain access, Delete “Apple world wide Developer relations certification authority” (Which expires on 14th Feb 2016) from both “Login” and “System” sections. If you can’t find it, use “Show Expired Certificates” in the View menu
Download AppleWWDRCA.cer and add it to Keychain access > certificates (which expires on 8th Feb 2023)
Everything should be back to normal and working now (Check the certificate is valid and it should be display in green)
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over ten thousand libraries and can help you scale your projects elegantly.
This article is updated with Swift 4 – Xcode 9 – iOS 11
Why to use a library everytime? 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
Declaration of Variables and Protocols (Delegate) :
Swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
protocol SlideMenuDelegate {
func slideMenuItemSelectedAtIndex(_ index : Int32)
}
class MenuViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
/**
* Array to display menu options
*/
@IBOutlet var tblMenuOptions : UITableView!
/**
* Transparent button to hide menu
*/
@IBOutlet var btnCloseMenuOverlay : UIButton!
/**
* Array containing menu options
*/
var arrayMenuOptions = [Dictionary<String,String>]()
/**
* Menu button which was tapped to display the menu
*/
var btnMenu : UIButton!
/**
* Delegate of the MenuVC
*/
vardelegate:SlideMenuDelegate?
}
Following method is for updating the Items in the Menu :
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.
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()
Swift
1
2
3
4
5
6
7
importUIKit
classHomeVC: BaseViewController{
overridefuncviewDidLoad(){
super.viewDidLoad()
addSlideMenuButton()
}
}
Source Code is available at the Github AKSwiftSlideMenu 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 :