Skip to content

Instantly share code, notes, and snippets.

View yannickl's full-sized avatar

Yannick Loriot yannickl

View GitHub Profile
@yannickl
yannickl / MyLocalizable.stringsdict
Created November 7, 2016 18:30
Variadic parameters for localization in swift
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>total_word</key>
<dict>
<key>NSStringLocalizedFormatKey</key>
<string>%#@value@</string>
<key>value</key>
<dict>
@yannickl
yannickl / EnumFailed.swift
Last active October 20, 2015 17:56
Behavior change between Debug and Release modes with XCode7 and Swift2
enum MyEnum {
case Foo
case Bar(param: Int)
case Baz
func isFoo() -> Bool {
if case .Foo = self {
return true
}
@yannickl
yannickl / AdjustHueComplement.swift
Last active August 29, 2015 14:25
DynamicColor Sample
let adjustHueColor = baseColor.adjustedHueColor(45 / 360)
let complementColor = baseColor.complementColor()
@yannickl
yannickl / WKWebViewExampleForRdar
Last active August 29, 2015 14:07
[rdar://18512488] WKWebView script message handler bug in iOS 8 and Xcode 6.0.1
//
// ViewController.swift
// TestWKWebView
//
// Created by Yannick Loriot on 01/10/14.
// Copyright (c) 2014 Yannick Loriot. All rights reserved.
//
import UIKit
import WebKit
@yannickl
yannickl / YLColor.swift
Last active September 16, 2023 03:55
Hex string <=> UIColor conversion in Swift
import Foundation
import UIKit
extension UIColor {
convenience init(hexString:String) {
let hexString:NSString = hexString.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
let scanner = NSScanner(string: hexString)
if (hexString.hasPrefix("#")) {
scanner.scanLocation = 1
@yannickl
yannickl / ZBarTest.h
Last active December 16, 2015 14:49
Here a little comparison between ZXing and ZBar in the point of view of the developer. The most important things is that ZXing is compiled using the Objective-C++ compiler (.mm) whereas ZBar is purely compile using the Objective-C compiler (.m).
#import <UIKit/UIKit.h>
#import "ZBarSDK.h"
@interface ZBarTest : NSObject <ZBarReaderDelegate>
@end