Skip to content

Instantly share code, notes, and snippets.

View norsez's full-sized avatar
💭
busy coding

Norsez Orankijanan norsez

💭
busy coding
View GitHub Profile
@norsez
norsez / JSONSaveLoad.swift
Created May 7, 2018 04:47
Load and Save JSON objects into a local file (written in Swift)
import Foundation
/**
Extension to save/load a JSON object by filename. (".json" extension is assumed and automatically added.)
*/
extension JSONSerialization {
static func loadJSON(withFilename filename: String) throws -> Any? {
let fm = FileManager.default
@norsez
norsez / TableSearchSampleiOS11.swift
Created May 24, 2018 09:43
Programmatically configure UISearchController and its result table in iOS 11 for an expensive search loop
// Created by Norsez Orankijanan on 17/5/2561 BE.
import UIKit
//MARK: a separate view controller for showing the search results works better with a storyboard or xib.
class ResultsTableViewController: UITableViewController {
var items = [String] ()
let CELLID = "CELLID"
override func viewDidLoad() {
super.viewDidLoad()
@norsez
norsez / isPalindrome
Last active February 28, 2019 09:38
isPalindrome in Swift 4.2
extension String {
var isPalindrome: Bool {
let reversed = String( self.reversed() )
for index in self.indices {
if self.lowercased()[index] != reversed.lowercased()[index] {
return false
}
}