Skip to content

Instantly share code, notes, and snippets.

@lludo
lludo / managedObjectModel
Created November 7, 2014 08:08
Initialize a managed object model with swift that will work for Tests and Application
lazy var managedObjectModel: NSManagedObjectModel = {
// The managed object model for the application.
let modelURL = NSBundle.mainBundle().URLForResource("<appName>", withExtension: "momd")!
let managedObjectModel = NSManagedObjectModel(contentsOfURL: modelURL)!
// Check is we are running as test or not
let environment = NSProcessInfo.processInfo().environment as [String : AnyObject]
let isTest = (environment["XCInjectBundle"] as? String)?.pathExtension == "xctest"
@lludo
lludo / String+Regex
Created November 6, 2014 21:37
String extension that returns a new string with matches of a regex replaced by a transformation
extension String {
func replace(regularExpression: NSRegularExpression, transform: (String) -> String) -> String {
var output = ""
var lastMatchedLocation = self.startIndex
let rangeAll = NSMakeRange(0, countElements(self));
regularExpression.enumerateMatchesInString(self, options: NSMatchingOptions(0), range: rangeAll) {
### Keybase proof
I hereby claim:
* I am lludo on github.
* I am lludo (https://keybase.io/lludo) on keybase.
* I have a public key whose fingerprint is BDF9 D7B7 6560 FBAE DE1D FA0E 8B90 0769 6A4C 38AB
To claim this, I am signing this object:
@lludo
lludo / gist:6186582
Last active December 20, 2015 19:58
Create a custom view by loading it's content from a nib and provide a viewDidLoad like on the viewControllers
@interface __class__ ()
@property (nonatomic, strong) UIView *rootNibView;
@end
@implementation __class__
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self loadView];
@lludo
lludo / gist:5267658
Last active December 15, 2015 13:29
Build and Package iOS Application for Jenkins (Ready for Testflight upload)
#!/bin/bash
# Configuration
KEYCHAIN_PASSWORD = <Pa$$w0rd>
WORKSPACE_FILE_NAME = <PongMadness>
SCHEME_NAME = <PongMadness Beta>
APP_NAME = <PongMadness-Beta>
# Update library dependencies
echo Building Dependencies