Skip to content

Instantly share code, notes, and snippets.

View caldofran's full-sized avatar

Rubén Méndez caldofran

View GitHub Profile
@caldofran
caldofran / gist:9763845
Created March 25, 2014 15:12
bug en appdelegate
- (void)changesSaved:(NSNotification *)notification {
if ([NSThread isMainThread]) {
[self changesSavedOnMainThread:notification];
}else{
@weakify(self);
dispatch_async(dispatch_get_main_queue(), ^{
@strongify(self);
[self changesSavedOnMainThread:notification];
});
}
- (CGSize)sizeForCellAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [self configureCommentCell:self.offScreenCommentCell forItemAtIndexPath:indexPath];
CGSize fittingSize = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
return CGSizeMake(self.collectionView.bounds.size.width, fittingSize.height);
}
@caldofran
caldofran / TestFlightBuildDetection
Created January 26, 2015 07:52
If you want your app to detect whether it’s running on a TestFlight build
[[[[NSBundle mainBundle] appStoreReceiptURL] lastPathComponent] isEqualToString:@"sandboxReceipt”];
@caldofran
caldofran / UIView+IBAddons.m
Created February 10, 2015 12:20
Extension to enjoy of custom properties in Interface Builder
#import <UIKit/UIKit.h>
IB_DESIGNABLE
@interface UIView (IBAddons)
// You could add more properties like that to have your custom properties in IB
@property (nonatomic, assign) IBInspectable CGFloat cornerRadius;
@end
@implementation UIView (IBAddons)
- (CGFloat)cornerRadius
@caldofran
caldofran / NSObject+debugCheck.h
Created June 30, 2015 09:30
Avoid attach runtime processes when debugging
//
// NSObject+debugCheck.h
// Reverse Me
//
// Created by Derek Selander on a happy day.
// Copyright (c) 2013 Derek Selander. All rights reserved.
//
#import <Foundation/Foundation.h>
#include <unistd.h>
@caldofran
caldofran / traditional_navigation_ios.swift
Last active November 20, 2019 14:16
Example of a very basic navigation on iOS
class ViewControllerA: UIViewController {
func presentViewControllerB() {
navigationController?.pushViewController(ViewControllerB(), animated: true)
}
}
@caldofran
caldofran / whole_navigation.swift
Created November 20, 2019 15:33
Whole navigation implementation: Navigation + Navigator
import UIKit
enum Navigation {
case section(Section)
case modal(Screen)
case push(Screen)
}
enum Section: Int {
case home
@caldofran
caldofran / example_navigation.swift
Last active March 3, 2020 15:02
An example of how to use the Navigator
navigator.handle(navigation: .section(.home))
navigator.handle(navigation: .modal(.offer(id: "1")))
navigator.handle(navigation: .push(.job(id: "1")))
@caldofran
caldofran / snapshot_result.txt
Last active March 4, 2020 14:22
An example of the result of a snapshot navigation test
▿ Navigation
▿ modal: (3 elements)
▿ .0: Screen
▿ viewController: <CandidateProcessViewController>
- id: "4224"
- .1: UIModalPresentationStyle.UIModalPresentationStyle
- completion: Optional<() -> ()>.none
@caldofran
caldofran / navigator.swift
Last active March 6, 2020 15:14
Simple Navigator implementation
class Navigator {
func handle(navigation: Navigation, animated: Bool = true) {
switch navigation {
case .section(let section):
tabBarController().selectedIndex = section.rawValue
case .modal(let screen):
topMostViewController().present(
screen.viewController(),
animated: animated