Skip to content

Instantly share code, notes, and snippets.

View DerAndereAndi's full-sized avatar
💭
Learning ...

Andreas Linde DerAndereAndi

💭
Learning ...
View GitHub Profile
@stig
stig / GitBundleVersionHook
Created August 10, 2013 09:11
Short script to set CFBundleShortVersionString from the latest tag + CFBundleVersion from the number of commits on the master branch. It is useful to use with Jenkins, and doesn't require you to update the repository, so you don't pollute your change history with "updated version" commits.
#!/bin/sh
# This script automatically sets the version and short version string of an
# Xcode project from the Git repository containing the project.
#
# To use this script in Xcode 4, add the contents to a "Run Script" build
# phase for your application target.
set -o errexit
set -o nounset
@brentsimmons
brentsimmons / gist:5810992
Last active January 3, 2021 02:22
Detect a tap on a URL inside a UITextView. Note: the rs_links method isn't included -- you'll need something that takes text and returns an array of detected links. This gist just demonstrates walking through the UITextView characters.
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;
@steipete
steipete / PSPDFUIKitMainThreadGuard.m
Last active May 27, 2024 12:11
This is a guard that tracks down UIKit access on threads other than main. This snippet is taken from the commercial iOS PDF framework http://pspdfkit.com, but relicensed under MIT. Works because a lot of calls internally call setNeedsDisplay or setNeedsLayout. Won't catch everything, but it's very lightweight and usually does the job.You might n…
// Taken from the commercial iOS PDF framework http://pspdfkit.com.
// Copyright (c) 2014 Peter Steinberger, PSPDFKit GmbH. All rights reserved.
// Licensed under MIT (http://opensource.org/licenses/MIT)
//
// You should only use this in debug builds. It doesn't use private API, but I wouldn't ship it.
// PLEASE DUPE rdar://27192338 (https://openradar.appspot.com/27192338) if you would like to see this in UIKit.
#import <objc/runtime.h>
#import <objc/message.h>
@steipete
steipete / PSPDFViewController.h
Last active June 6, 2017 03:56
This method will help to prevent a lot of emails about "weird bugs".
// Defines a yet undocumented method to add a warning if super isn't called.
#ifndef NS_REQUIRES_SUPER
#if __has_attribute(objc_requires_super)
#define NS_REQUIRES_SUPER __attribute((objc_requires_super))
#else
#define NS_REQUIRES_SUPER
#endif
#endif
@interface UIViewController (SubclassingWarnings)
@skabber
skabber / hockeyCrashes.py
Created April 10, 2013 23:22
A Python script to graph all your production app crashes in Status Board
#!/usr/bin/env python
import requests
import json
import StringIO
import datetime
hockeyToken = 'getyourowndamnkey'
appsEndpoint = 'https://rink.hockeyapp.net/api/2/apps'
crashesEndpoint = 'https://rink.hockeyapp.net/api/2/apps/%s/crashes/histogram?api_token=%s&format=json&start_date=%s&end_date=%s'
@ccgus
ccgus / Xcode crash report
Created February 23, 2013 19:02
Xcode crash report whoa
Application Specific Information:
ProductBuildVersion: 4H127
ASSERTION FAILURE in /SourceCache/IDEInterfaceBuilder/IDEInterfaceBuilder-3084/Framework/Connections/Interface/IBConnectionPopUpMenu.m:388
Details: Need a menu.
Function: NSMenuItem *IBPopUpConnectionMenuWithMenuItems(NSArray *, NSMenuItem *, NSEvent *, NSRect, BOOL, NSSet *, CGFloat, NSWindow *, NSColor *, NSColor *, NSColor *, NSColor *, id<IBConnectionPopUpMenuDelegate>)
Thread: <NSThread: 0x40030a1e0>{name = (null), num = 1}
Hints: None
Backtrace:
0 0x000000010c77b249 -[IDEAssertionHandler handleFailureInFunction:fileName:lineNumber:messageFormat:arguments:] (in IDEKit)
1 0x000000010ba2ec65 _DVTAssertionHandler (in DVTFoundation)
@CodaFi
CodaFi / CFIAlternatingTableView.m
Last active December 16, 2016 07:29
Used in conjunction with a Cell-Based NSTableView to draw an iTunes-11 Style table view rows, along with fake rows on the top and bottom of the Table View. The clip view mentioned in the implementation does no actual drawing, and can be eliminated in favor of another arbitrary clip view or removed entirely. This gist uses the clip view swapping …
//
// CFIAlternatingTableView.m
//
// Created by Robert Widmann on 1/6/13.
// Copyright (c) 2015 CodaFi. All rights reserved.
//
#import "CFIAlternatingTableView.h"
#import "CFIAlternatingClipView.h"
@krzysztofzablocki
krzysztofzablocki / gist:4396302
Last active November 24, 2021 19:17
Set symbol breakpoint on objc_msgSend then setup this debug command to log all methods called in iOS Simulator. If you want to do device debugging change esp+4 register to r0, esp+8 to r1 Found long ago somewhere on stackoverflow.
expr -- (void)printf("[%s, %s]\n",(char *) object_getClassName(*(long*)($esp+4)), (char *) *(long *)($esp+8) )
@Gi-lo
Gi-lo / gist:4279932
Created December 13, 2012 21:11
Easily create GET NSURLs in Objective-C. (Used in https://github.com/Gi-lo/GCXHTTPOperation )
- (NSURL *)URLWithString:(NSString *)string andQueryValuesForKeys:(NSString *)value, ... {
if (!value) {
return [NSURL URLWithString:string];
}
NSMutableString *queryString = [NSMutableString string];
NSString *argument = nil;
NSUInteger argumentCount = 0;
va_list argumentList;
@jonathanpenn
jonathanpenn / gist:3792241
Created September 27, 2012 04:58
Using to-many predicates with UIAutomation
// Based on this discussion:
// https://twitter.com/listrophy/statuses/251074683594747904
// To setup:
// Create an application that has a tableView with a couple cells in it, one of
// which has the "coffee" in it's label
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var window = app.mainWindow();