Skip to content

Instantly share code, notes, and snippets.

View nuthatch's full-sized avatar

Stephen Ryner Jr. nuthatch

View GitHub Profile
-(IBAction)show:(id)sender{
CGRect frame = [aView frame];
frame.origin.y = [[self view] bounds].size.height;
[aView setFrame:frame];
[[self view] addSubview:aView];
[UIView beginAnimations:@"slide up" context:NULL];
frame.origin.y = [[self view] bounds].size.height - frame.size.height;
[aView setFrame:frame];
[UIView commitAnimations];
@soffes
soffes / betterway.m
Created September 13, 2010 19:57
Is there a better way?
// Original
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
static NSString *firstLaunchKey = @"firstLaunch";
// Register default defaults
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
NSDictionary *defaultDefaults = [[NSDictionary alloc] initWithObjectsAndKeys:
[NSNumber numberWithBool:YES], firstLaunchKey,
nil];
@zssz
zssz / gist:846696
Created February 27, 2011 23:33
Demo
//
// IZGoogleGeocoder.m
// JSON Google Geocoder
//
// Created by Zsombor Szabó on 2/11/11.
// Copyright 2011 IZE. All rights reserved.
//
#import "IZGoogleGeocoder.h"
@nuthatch
nuthatch / gist:983606
Created May 20, 2011 19:31
set Typeface to all TextViews in a ViewGroup for Android
// recursively apply typeface to our textviews
static final void setTypeface(ViewGroup viewGroup, Typeface typeface)
{
if (viewGroup == null) return;
int children = viewGroup.getChildCount();
Log.d(TAG, "setTypeface " + viewGroup + " : " + children);
for (int i=0; i<children; i++)
{
View view = viewGroup.getChildAt(i);
@leighmcculloch
leighmcculloch / NSString_stripHtml.h
Last active February 21, 2018 22:45
NSString + Strip HTML
// NSString_stripHtml.h
// Copyright 2011 Leigh McCulloch. Released under the MIT license.
#import <Foundation/Foundation.h>
@interface NSString (stripHtml)
- (NSString*)stripHtml;
@end
@justin
justin / gist:1586083
Created January 10, 2012 00:56
UIAccessibilityTraits Example
- (UIAccessibilityTraits)accessibilityTraits
{
UIAccessibilityTraits traits = UIAccessibilityTraitButton | UIAccessibilityTraitAllowsDirectInteraction | UIAccessibilityTraitStaticText;
if (self.disabled == YES)
{
traits = traits | UIAccessibilityTraitNotEnabled;
}
return traits;
@cbarrett
cbarrett / gist:1642401
Created January 19, 2012 20:31
Had this laying around for quite a while -- really useful and kind of dumb it's not built in...
// stringByAddingPercentEscapesUsingEncoding is pretty conservative about escaping characters, which is fine most of the time. This method however escapes *all special characters*, allowing any arbitrary string to be used when building any part of a URL.
// (c) 2011 Springs & Struts. Released under MIT-style license. See: http://www.opensource.org/licenses/mit-license.php
@interface NSString (SSURLEscaping)
- (NSString *)ss_stringByEscapingAllURLCharactersForRealWithEncoding:(NSStringEncoding)encoding;
@end
@implementation NSString (SSURLEscaping)
- (NSString *)ss_stringByEscapingAllURLCharactersForRealWithEncoding:(NSStringEncoding)encoding
@dhoerl
dhoerl / AppDelegate(category).m
Created July 26, 2012 23:19
Keychain Wrapper for dictionary (NSData) not a single NSString
static NSString *kcIdentifier = @"MyApp";
@implementation LTAppDelegate (KeyChain)
- (void)keychainInit
{
self.keychainDict = [NSMutableDictionary dictionaryWithCapacity:7];
KeychainItemWrapper *item = [[KeychainItemWrapper alloc] initWithIdentifier:kcIdentifier accessGroup:nil];
[self.keychainDict setObject:@"" forKey:kcEmailAddress];
@drance
drance / gist:4546014
Created January 16, 2013 09:57
Workaround to vanilla UICollectionView+UICollectionViewFlowLayout using non-integral origins, leading to blurry cells.
@implementation BHSCollectionViewFlowLayout
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSArray *allAttrs = [super layoutAttributesForElementsInRect:rect];
for (UICollectionViewLayoutAttributes *attributes in allAttrs) {
attributes.frame = CGRectIntegral(attributes.frame);
}
return allAttrs;
}
@interface NSManagedObject (Serialization)
- (NSDictionary*) toDictionary;
- (void) populateFromDictionary:(NSDictionary*)dict;
+ (NSManagedObject*) createManagedObjectFromDictionary:(NSDictionary*)dict
inContext:(NSManagedObjectContext*)context;
@end