Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Shaps shaps80

🏠
Working from home
View GitHub Profile
@shaps80
shaps80 / SPXEncodingDefines.h
Created Mar 13, 2014
NSCoding and NSUserDefaults Defines - Clean macros to simplify your life
View SPXEncodingDefines.h
/*
Copyright (c) 2014 Shaps Mohsenin. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
View gist:9590376
typedef NS_ENUM(NSInteger, kErrorCode) {
kErrorCodeInternal = 431432,
};
extern NSError *NSErrorMake(NSString *message, NSInteger code, NSDictionary *aUserInfo, NSString *methodOrFunction);
#define NSObjcAssert NSAssert
#define InvalidConditionString(condition) (@"Invalid condition not satisfying: " #condition)
#define GenericAssertCondition(ctype, condition) NS ## ctype ## Assert((condition), InvalidConditionString((condition)))
#define GenericErrorMake(condition, func) NSErrorMake(InvalidConditionString((condition)), kErrorCodeInternal, nil, func)
View keybase.md

Keybase proof

I hereby claim:

  • I am shaps80 on github.
  • I am shaps (https://keybase.io/shaps) on keybase.
  • I have a public key whose fingerprint is D1B3 44E7 F8A9 EF64 D1E0 4292 4286 651A F5BD CB47

To claim this, I am signing this object:

View UIView+OptionalAnimations.h
@interface UIView (SPXAdditions)
+ (void)animate:(BOOL)shouldAnimate duration:(CGFloat)duration animations:(void (^)(void))animations;
+ (void)animate:(BOOL)shouldAnimate duration:(CGFloat)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion;
+ (void)animate:(BOOL)shouldAnimate duration:(CGFloat)duration delay:(CGFloat)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL))completion;
+ (void)animate:(BOOL)shouldAnimate duration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL))completion;
+ (void)transition:(BOOL)shouldTransition fromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL))completion;
+ (void)transition:(BOOL)shoul
@shaps80
shaps80 / AsyncKiwiTest.m
Created May 22, 2014
The following is the test I have written but it never asserts from my tests. I think the issue is that the assertion occurs on a different thread that the one that the task is performed on, that perhaps this isn't getting back to the test.
View AsyncKiwiTest.m
it (@"should eventually throw assert for asynchronous operation", ^{
[[theBlock(^{
[MyClass performLongRunningAsynchronousTasks];
}) shouldEventually] raise];
});
@shaps80
shaps80 / UIApplication+SnippexAdditions.h
Last active Aug 29, 2015
Check if running inside an App Extension vs an App
View UIApplication+SnippexAdditions.h
@import Foundation;
@interface UIApplication (SnippexAdditions)
+ (BOOL)isAppExtension;
@end
@shaps80
shaps80 / SLBarButtonItem.h
Last active Dec 18, 2015
I've often found myself a more convenient way to add a simple barButtonItem to a navigation or tool bar, so I created this nice little subclass.
View SLBarButtonItem.h
#import <UIKit/UIKit.h>
@class SLBarButtonItem;
typedef void (^SLBarButtonItemCompletionBlock)(SLBarButtonItem *sender);
@interface SLBarButtonItem : UIBarButtonItem
+(SLBarButtonItem *)barButtonSystemItem:(UIBarButtonSystemItem)systemItem;
+(SLBarButtonItem *)barButtonWithTitle:(NSString *)title style:(UIBarButtonItemStyle)style;
@shaps80
shaps80 / EncodingDefines.h
Last active Dec 19, 2015
Custom macros to provide better handling of encoding and decoding values. See my blog post for more detailed information: http://shaps.me/to-encode-or-to-decode
View EncodingDefines.h
/*
Copyright (c) 2014 Shaps Mohsenin. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
@shaps80
shaps80 / SPXDefines.h
Last active Dec 19, 2015
This is a common definitions file I use across many projects for convenience.
View SPXDefines.h
/*
Copyright (c) 2013 Snippex. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
@shaps80
shaps80 / ImplementsSelectorSample.m
Last active Dec 21, 2015
Determine if a subclass implements a specific selector.
View ImplementsSelectorSample.m
if ([MyView implementsSelector:@selector(someMethod:)])
NSLog(@"Implemented");