Skip to content

Instantly share code, notes, and snippets.

Daniel Phillips danielphillips

Block or report user

Report or block danielphillips

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:5682765
@interface SomeViewController : UIViewController
@end
@implementation SomeViewController
- (IBAction)show:(id)sender
{
UIImagePickerController *pickerController = [UIImagePickerController new];
[pickerController setDelegate:(id)self];
@danielphillips
danielphillips / gist:5490060
Created Apr 30, 2013
Show off all of an NSURL
View gist:5490060
NSDictionary *urlStuff = @{
@"absoluteString" : URL.absoluteString ? URL.absoluteString : @"nil",
@"relativeString" : URL.relativeString ? URL.relativeString : @"nil",
@"scheme" : URL.scheme ? URL.scheme : @"nil",
@"resourceSpecifier" : URL.resourceSpecifier ? URL.resourceSpecifier : @"nil",
@"host" : URL.host ? URL.host : @"nil",
@"port" : URL.port ? URL.port : @"nil",
@"user" : URL.user ? URL.user : @"nil",
@"password" : URL.password ? URL.password : @"nil",
@"path" : URL.path ? URL.path : @"nil",
View listFonts.m
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:indFamily]]];
@danielphillips
danielphillips / NSString+Crypto.h
Last active Dec 17, 2016
NSString Crypto category
View NSString+Crypto.h
#import <Foundation/Foundation.h>
#import <CommonCrypto/CommonHMAC.h>
@interface NSString (Crypto)
- (NSString *)md5;
+ (NSString *)encodeBase64WithString:(NSString *)strData;
+ (NSString *)encodeBase64WithData:(NSData *)objData;
+ (NSData *)decodeBase64WithString:(NSString *)strBase64;
- (NSString*)sha1;
@danielphillips
danielphillips / DPAnnotationView.h
Last active Feb 25, 2016
MKAnnotationView subclass to implement lift and drop animations for your custom map pin. Use this in exactly the same was as MKPinAnnotationView or use the implementation in conjunction with your existing MKAnnotationView subclass.
View DPAnnotationView.h
#import <MapKit/MapKit.h>
@interface DPAnnotationView : MKAnnotationView
@property (nonatomic, assign) MKMapView *mapView;
@end
View gist:3734823
- (IBAction)showWalkingDirections:(id)sender {
if ([self.parkingDetails.mapItem respondsToSelector:@selector(openInMapsWithLaunchOptions:)]) {
NSDictionary *launchOptions = @{
MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeWalking,
MKLaunchOptionsMapTypeKey : [NSNumber numberWithInt:MKMapTypeStandard]
};
[self.parkingDetails.mapItem openInMapsWithLaunchOptions:launchOptions];
} else {
NSString *mapURL = @"http://maps.google.com/maps?";
@danielphillips
danielphillips / DJPAppDelegate.h
Created Feb 8, 2012
Create a solid colour (no Apple gloss) UINavigationBar
View DJPAppDelegate.h
@interface DJPAppDelegate : UIResponder <UIApplicationDelegate, UIAppearanceContainer>
@end
@danielphillips
danielphillips / UILabel+GetLines.h
Created Jun 9, 2011
Get number of lines required for a UILabel
View UILabel+GetLines.h
@interface UILabel (GetLines)
- (NSArray*) lines;
@end
@danielphillips
danielphillips / UILabel+dynamicSizeMe.h
Created Jun 2, 2011
Adjust UILabel to change it's frame according to it's content
View UILabel+dynamicSizeMe.h
@interface UILabel (dynamicSizeMe)
-(float)resizeToFit;
-(float)expectedHeight;
@end
@danielphillips
danielphillips / DJPWebView.h
Created Apr 28, 2011
UILabel rich text solution using UIWebView
View DJPWebView.h
#import "DJPWebViewDelegate.h"
#import "DJPWebViewContent.h"
@interface DJPWebView : UIWebView {
DJPWebViewDelegate* delegateObject;
DJPWebViewContent* content;
}
@property(nonatomic, retain)DJPWebViewContent* content;
You can’t perform that action at this time.