Skip to content

Instantly share code, notes, and snippets.

@zypsg
zypsg / uiunderlinebutton.h
Created March 27, 2012 09:52
iOS: Underline the title of a UIButton
@interface UIUnderlinedButton : UIButton
+ (UIUnderlinedButton*) underlinedButton;
@end
@steipete
steipete / gist:3713233
Created September 13, 2012 09:39
I often use dispatch queues for locking, and this function just makes life SO MUCH EASIER. Accidental deadlocks in more complex code paths are a PITA otherwise. But Apple deprecated dispatch_get_current_queue with iOS6?
nline void pspdf_dispatch_sync_reentrant(dispatch_queue_t queue, dispatch_block_t block) {
dispatch_get_current_queue() == queue ? block() : dispatch_sync(queue, block);
}
@subdigital
subdigital / pns.m
Created January 5, 2013 21:59
What are your favorite Xcode Snippets? Add them in the comments.
// Property Nonatomic Strong
// Platform: All
// Completion Scopes: ClassInterfaceMethods
@property (nonatomic, strong) <# class_name #> *<# variable_name #>;
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active August 20, 2024 12:46
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@jaybaird
jaybaird / Analytics.h
Created February 5, 2013 01:45
Sensible analytics functions using LLVM's overloadable
NSString * eventForCategoryAction(NSString *category, NSString *action) {
return [NSString stringWithFormat:@"%@:%@", (category) ? category : @"default", action]
}
void __attribute__((overloadable)) TrackEvent(NSString *category, NSString *action, NSDictionary *infoDict) {
[Flurry trackEvent:eventForCategory(category, action) withParameters:infoDict];
}
void __attribute__((overloadable)) TrackEvent(NSString *category, NSString *action) {
TrackEvent(category, action, nil);
@mayoff
mayoff / makeAnimatedGif.m
Created February 16, 2013 23:00
Example of creating an animated GIF on iOS, with no 3rd-party code required. This should also be easy to port to OS X.
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
static UIImage *frameImage(CGSize size, CGFloat radians) {
UIGraphicsBeginImageContextWithOptions(size, YES, 1); {
[[UIColor whiteColor] setFill];
UIRectFill(CGRectInfinite);
CGContextRef gc = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(gc, size.width / 2, size.height / 2);
@0xced
0xced / NSObject+Subclasses.h
Last active September 4, 2017 06:37
NSObject category to get subclasses
#import <Foundation/Foundation.h>
@interface NSObject (Subclasses)
+ (NSSet *) subclasses_xcd;
@end
@mattt
mattt / uiappearance-selector.md
Last active June 4, 2024 13:28
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
#import <Foundation/Foundation.h>
#import <mach/mach_time.h> // for mach_absolute_time() and friends
// clang -g -fobjc-arc -Weverything -Wno-unused-parameter -framework Foundation -o iteration iteration.m
// Run this by passing arguments on the command line. Run without any
// arguments to see the supported flags. Each time a flag is used causes
// that test to be run and timed, with the time (in seconds) output when
// it finishes. Be careful not to do anything else on your machine (such
// as surfing Redding while getting bored looking at the terminal) otherwise
@indragiek
indragiek / gist:5297435
Last active March 5, 2023 21:55
Draft of a ReactiveCocoa based interface for CoreData
//
// FGOManagedObjectContextStack.h
//
// Created by Indragie Karunaratne on 2012-12-23.
//
#import <Foundation/Foundation.h>
typedef void (^FGOConfigurationBlock)(id);