This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// PSDDFormatter.h | |
// Created by Peter Steinberger on 08.09.10. | |
// | |
#import "DDLog.h" | |
@interface PSDDFormatter : NSObject <DDLogFormatter> { | |
NSDateFormatter *dateFormatter; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////////////////////////////////////////////////////////////////////// | |
#pragma mark - | |
#pragma mark Key/Value coding | |
- (id)initWithCoder:(NSCoder *)aCoder { | |
if (self = [self init]) { | |
[TPAutoArchiver unarchiveObject:self | |
withCoder:aCoder]; | |
} | |
return self; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// some credits go to http://www.mikeash.com/pyblog/friday-qa-2009-08-14-practical-blocks.html | |
typedef void (^BasicBlock)(void); | |
void RunAfterDelay(NSTimeInterval delay, BasicBlock block) { | |
[[[block copy] autorelease] performSelector:@selector(ps_callBlock) withObject:nil afterDelay:delay]; | |
} | |
@implementation NSObject (BlocksAdditions) | |
- (void)ps_callBlock { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)login { | |
// build request | |
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:[NSURL URLWithString:url]]; | |
#ifdef MOCK_HANDSHAKE | |
// create a nice mock | |
request = [OCMockObject niceMockForClass:[ASIHTTPRequest class]]; | |
NSString *modelPath = [[NSBundle mainBundle] pathForResource:@"mock_handshake" ofType:@"txt"]; | |
NSString *responseString = [NSString stringWithContentsOfFile:modelPath encoding:NSUTF8StringEncoding error:nil]; | |
[[[(id)request stub] andReturn:responseString] responseString]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// only add the http link | |
NSError *error = nil; | |
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(http[^^]+)" options:NSRegularExpressionCaseInsensitive error:&error]; | |
NSTextCheckingResult *firstMatch = [regex firstMatchInString:responseString options:0 range:NSMakeRange(0, [responseString length])]; | |
if (firstMatch) { | |
NSRange accessTokenRange = [firstMatch rangeAtIndex:1]; | |
NSString *theUrlString = [responseString substringWithRange:accessTokenRange]; | |
NSLog(theUrlString); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is implemented, but not declared. we add the category to fix the warning | |
// (since super cannot be casted any longer in clang) | |
@interface UINavigationController(AMInternal) | |
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item; | |
@end | |
@implementation AMNavigationController | |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <PSPDFKit/PSPDFKit.h> | |
// Create the PSPDFDocument. (container for one or multiple pdfs) | |
NSURL *documentURL = [NSBundle.mainBundle.resourceURL URLByAppendingPathComponent:@"Sample.pdf"]; | |
PSPDFDocument *document = [PSPDFDocument documentWithURL:documentURL]; | |
// Open view controller. Embed into an UINavigationController to enable the toolbar. | |
PSPDFViewController *pdfController = [[PSPDFViewController alloc] initWithDocument:document]; | |
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:pdfController]; | |
[self presentViewController:navController animated:YES completion:NULL]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kPSPDFLogLevel = PSPDFLogLevelInfo; | |
// Available Log Levels: PSPDFLogLevelNothing, PSPDFLogLevelError, PSPDFLogLevelInfo, PSPDFLogLevelVerbose |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *)pspdf_preloadedImage { | |
CGImageRef image = self.CGImage; | |
// make a bitmap context of a suitable size to draw to, forcing decode | |
size_t width = CGImageGetWidth(image); | |
size_t height = CGImageGetHeight(image); | |
CGColorSpaceRef colourSpace = CGColorSpaceCreateDeviceRGB(); | |
CGContextRef imageContext = CGBitmapContextCreate(NULL, width, height, 8, width*4, colourSpace, | |
kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)setSelected:(BOOL)selected animated:(BOOL)animated { | |
selected_ = selected; | |
if (animated) { | |
CATransition *transition = [CATransition animation]; | |
transition.duration = 0.25f; | |
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; | |
transition.type = kCATransitionFade; | |
[self.selectionImageView.layer addAnimation:transition forKey:nil]; | |
} |
OlderNewer