Skip to content

Instantly share code, notes, and snippets.

Delord Kévin kevindelord

View GitHub Profile
View How_To_SwiftyJSON
// This very useful code parses a `.json` file using the library SwiftyJSON.
// Add this in a class, maybe in your Data Manager:
class func addDefaultEntities() {
if let file = NSBundle(forClass:AppDelegate.self).pathForResource(JSON.Constants.FileName, ofType: JSON.Constants.Type) {
if let data = NSData(contentsOfFile: file) {
for (index: String, bookJSON: JSON) in JSON(data:data) {
let dict = bookJSON.dictionaryObject
// do something with the dictionary
}
@kevindelord
kevindelord / hockey_deploy.py
Created Sep 7, 2015
Build, archive and push a new iOS app version
View hockey_deploy.py
#!/usr/bin/python
import sys
import argparse
import os
import subprocess
parser = argparse.ArgumentParser(description='Build, archive and push a new iOS app version!')
parser.add_argument('-w','--workspace', help='Path to workspace', required=True, default=None)
parser.add_argument('-s','--scheme', help='Scheme name to build', required=True, default=None)
@kevindelord
kevindelord / UIImage+Autoresize.h
Last active Jun 6, 2016
UIImage extension to automatically generate a valid UIImage on iPhone using an asset corresponding to the actual device screen size. If needed, this code will add the following image suffix: @2x, -568h@2x, -667h@2x, @3x.
View UIImage+Autoresize.h
//
// UIImage+Autoresize.h
// UIImage+Autoresize
//
// Created by kevin delord on 24/04/14.
// Copyright (c) 2014 Kevin Delord. All rights reserved.
//
// Full library and documentation here: https://github.com/kevindelord/UIImage-Autoresize
//
#ifndef UIImage_Autoresize_h__
@kevindelord
kevindelord / etag
Last active Jun 10, 2020
How to integrate Etag in Swift
View etag
let API_HEADER_FIELD_NONE_MATCH : String = "If-None-Match"
let API_HEADER_FIELD_ETAG : String = "Etag"
let API_REQUEST_SUCCESS : Int = 200
func ETagForURL(urlString: String) -> String? {
// return the saved ETag value for the given URL
return NSUserDefaults.standardUserDefaults().objectForKey(urlString) as String?
}
You can’t perform that action at this time.