Skip to content

Instantly share code, notes, and snippets.

View f-meloni's full-sized avatar
:octocat:
Opensource Lover

Franco Meloni f-meloni

:octocat:
Opensource Lover
View GitHub Profile
@f-meloni
f-meloni / CellUtilities-Swift2.2.swift
Last active September 5, 2019 08:25
Cells reusableIdentifier and nib utility extension
import Foundation
import UIKit
public protocol Reusable: class, NSObjectProtocol {
static var reusableIdentifier: String { get }
}
public extension Reusable {
public static var reusableIdentifier: String { return String(Self) }
}
@f-meloni
f-meloni / NSURL+QueryDictionary.swift
Created August 10, 2016 14:06
NSURL swift extension that parses URL query string into [String: AnyObject] dictionary, using NSURLComponents and supporting array for values that uses ',' to separate array items
extension NSURL {
var queryDictionary: [String: AnyObject]? {
return NSURLComponents(URL: self, resolvingAgainstBaseURL: false)?
.queryItems?
.reduce([:], combine: { (var result: [String: AnyObject], queryItem) -> [String: AnyObject] in
if queryItem.value?.containsString(",") ?? false {
let array = queryItem.value?.componentsSeparatedByString(",")
result[queryItem.name] = array
}