Skip to content

Instantly share code, notes, and snippets.

View anas-p's full-sized avatar
🎯
Focusing

Anas Poovalloor anas-p

🎯
Focusing
View GitHub Profile
@anas-p
anas-p / Guard.swift
Last active May 13, 2017 07:08
It represents the 'guard' usability in Swift, compared to normal 'if else' and optional binding 'let' statements.
//
// guard.swift
// Created by Anas Zaheer on 12/05/17.
// Copyright © 2017 nfnlabs. All rights reserved.
//
import Foundation
//This is the most basic style to make sure a value exists and that meets a condition
func manualCheck(x: Int?) {
@anas-p
anas-p / Access_iCloudDrive_files.swift
Created August 28, 2017 13:12
Access file from iCloud Drive
class Access_iCloudDrive_files: UIViewController, UIDocumentPickerDelegate{
func show_iCloudDrive_All_Files(){
let documentPicker = UIDocumentPickerViewController(documentTypes: ["Public.data"], in: .import)
documentPicker.delegate = self
documentPicker.modalPresentationStyle = .formSheet
self.present(documentPicker, animated: true, completion: nil)
}
//MARK: UIDocumentPickerDelegate
@anas-p
anas-p / RemoveDuplicate.swift
Last active November 10, 2017 09:49
Remove duplicate from array WITHOUT SORTING
class RemoveDuplicateFromArray: NSObject {
//MARK: -Remove duplicates from 'String' Array without any sorting
func removeDuplicates(array: [String]) -> [String] {
var encountered = Set<String>()
var result: [String] = []
for value in array {
if encountered.contains(value) {
// Do not add a duplicate element.
}
@anas-p
anas-p / CoreDataStack.swift
Created October 4, 2017 10:35
iCloud sync and create AppGroup core data for both extension and App (Single DB).
//
// CoreDataStack.swift
// Created by Anas Zaheer on 24/09/17.
// Copyright © 2017 nfnlabs. All rights reserved.
//
import UIKit
import CoreData
@anas-p
anas-p / IAP_Helper.swift
Last active November 9, 2017 07:06
In App Purchase Helper class - Purchase & Restore
// Created by Anas Zaheer on 31/10/17.
// Copyright © 2017 nfnlabs. All rights reserved.
import UIKit
import StoreKit
enum IAPs:string{
case IAP_Plan = "com.company.app.iap"
}
@anas-p
anas-p / InAppManager.swift
Created November 5, 2017 14:06
In App Purchase and Receipt verification using SwiftyStoreKit
// Created by Anas Zaheer on 25/09/17.
// Copyright © 2017 nfnlabs. All rights reserved.
import UIKit
import Foundation
import SwiftyStoreKit
import StoreKit
enum IAP_Secret:String {
case sharedSecret = "be5xxxxxxxxxxxxxx82cdre"
@anas-p
anas-p / install_cocoapod
Last active May 14, 2018 13:21
Facebook Account Kit using Swift
$ sudo gem install cocoapods
$ pod init
@anas-p
anas-p / addPod
Last active May 14, 2018 13:21
Facebook Account Kit using Swift
pod 'AccountKit'
@anas-p
anas-p / podInstall
Last active May 14, 2018 13:20
Facebook Account Kit using Swift
$ pod install
@anas-p
anas-p / info.plist
Last active May 14, 2018 13:20
Facebook Account Kit using Swift
<plist version="1.0">
<dict>
...
<key>FacebookAppID</key>
<string>{your-app-id}</string>
<key>AccountKitClientToken</key>
<string>{your-account-kit-client-token}</string>
<key>CFBundleURLTypes</key>
<array>
<dict>