Skip to content

Instantly share code, notes, and snippets.

View DougFischer's full-sized avatar

Douglas Fischer DougFischer

View GitHub Profile
@DougFischer
DougFischer / GiveMyModalsOrientationsBack
Created October 9, 2013 05:09
On iOS6+, the orientation of modal view controllers is handled by the view controller who present them. If you're using UITabBarController, it can be a little confusing, since you need to add presenting view controller some code to handle the modal controller's visibility. This code snippet shows how to have all UIViewControllers orientations (p…
#pragma mark -
#pragma mark UIApplication Delegate
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)pWindow {
UITabBarController *tabCtrl = (UITabBarController *)self.window.rootViewController;
//Check if there's a modal view controller on screen (dismissing modal view controllers are ignored)
if (tabCtrl.selectedViewController.presentedViewController && !tabCtrl.selectedViewController.presentedViewController.isBeingDismissed) {
return tabCtrl.selectedViewController.presentedViewController.supportedInterfaceOrientations;
}
//ANTES
DOLARC = (
"IDX: DOLARC | Date: 28 | Value: 2.18",
"IDX: DOLARC | Date: 29 | Value: 2.18",
"IDX: DOLARC | Date: 30 | Value: 2.19",
"IDX: DOLARC | Date: 31 | Value: 2.20",
"IDX: DOLARC | Date: 1 | Value: 2.25",
"IDX: DOLARC | Date: 4 | Value: 2.24",
"IDX: DOLARC | Date: 5 | Value: 2.27",
@DougFischer
DougFischer / SubtrateUncomparablePointsRESULT_DATA
Last active December 29, 2015 09:48
SubtrateUncomparablePointsRESULT_DATA
Printing description of dictionaryWithValuesByKeys:
{
DOLARC = (
"IDX: DOLARC | Date: 28 | Value: 2.18",
"IDX: DOLARC | Date: 29 | Value: 2.18",
"IDX: DOLARC | Date: 30 | Value: 2.19",
"IDX: DOLARC | Date: 31 | Value: 2.20",
"IDX: DOLARC | Date: 1 | Value: 2.25",
"IDX: DOLARC | Date: 4 | Value: 2.24",
"IDX: DOLARC | Date: 5 | Value: 2.27",
- (void)subtrateUncomparablePoints {
//Dictionary to store the values before and after subtration
NSMutableDictionary *dictionaryWithValuesByKeys = _plotPoints;
NSMutableDictionary *filteredDictionary = [[NSMutableDictionary alloc] init];
//Store the dates that must be displayed
NSCountedSet *countedSet = [[NSCountedSet alloc] init];
//Iterate all points and count how many times date is found
for (NSArray *values in [dictionaryWithValuesByKeys allValues]) {
- (id)init {
self = [super init];
if (self) {
loadedThumbnails = [[NSCache alloc] init];
[loadedThumbnails setCountLimit:10];
}
return self;
}
- (UIImage *)thumbnailForPDFOfPath:(NSString *)path {
@DougFischer
DougFischer / AppDelegate.m
Last active January 4, 2016 18:49
Programmatically open dropdown or combobox on UIWebView
//
// AppDelegate.m
// DOMTest
//
// Created by Douglas Fischer on 1/28/14.
// Copyright (c) 2014 Abacomm Brasil. All rights reserved.
//
#import "AppDelegate.h"
#import "TestViewController.h"
- (BOOL)textField:(UITextField *)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString *)string {
autocompleteTableView.hidden = NO;
NSString *substring = [NSString stringWithString:textField.text];
substring = [substring
stringByReplacingCharactersInRange:range withString:string];
[self searchAutocompleteEntriesWithSubstring:substring];
return YES;
2014-07-18 20:02:39.508 CCH[37414:60b] Sync JSON: {
availableQuestions = (
{
allowAttachments = 0;
description = "Planeja a visita utilizando o Modelo de Visita M\U00e9dica GSK, para estabelecer uma comunica\U00e7\U00e3o eficaz.";
groupName = "Aptid\U00e3o em vendas";
guid = 25;
label = "Pr\U00e9-visita";
options = (
{
[ServicesBox] JSON: {
accountGuid = 1;
collectData = (
{
accountGuid = 1;
answers = (
{
answer = {
date = 0;
optionGuid = (
@DougFischer
DougFischer / XCodeTurnTODOandFIXMEintoWarnings.sh
Last active September 9, 2016 21:58
Put this code as post build script on XCode to turn TODO, NOT_IMPLEMENTED and FIXME into XCode warnings.
KEYWORDS="TODO|NOT_IMPLEMENTED|FIXME|\?\?\?:|\!\!\!:"
find "${SRCROOT}" \( -name "*.h" -or -name "*.m" \) -and \( -path "${SRCROOT}/Pods/*" -prune -o -print0 \) | xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | perl -p -e "s/($KEYWORDS)/ warning: \$1/"