Skip to content
Browse files

First commit of the example.

  • Loading branch information...
0 parents commit e341ecd997fcbe47d320c369f30546151041a487 @iamamused committed
2 .gitignore
@@ -0,0 +1,2 @@
+AssetsFromPDF.xcodeproj/project.xcworkspace
+AssetsFromPDF.xcodeproj/xcuserdata
312 AssetsFromPDF.xcodeproj/project.pbxproj
@@ -0,0 +1,312 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ DD582B9A150110E600D33D61 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD582B99150110E600D33D61 /* UIKit.framework */; };
+ DD582B9C150110E600D33D61 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD582B9B150110E600D33D61 /* Foundation.framework */; };
+ DD582B9E150110E600D33D61 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DD582B9D150110E600D33D61 /* CoreGraphics.framework */; };
+ DD582BA4150110E600D33D61 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DD582BA2150110E600D33D61 /* InfoPlist.strings */; };
+ DD582BA6150110E600D33D61 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DD582BA5150110E600D33D61 /* main.m */; };
+ DD582BAA150110E600D33D61 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DD582BA9150110E600D33D61 /* AppDelegate.m */; };
+ DD582BAD150110E600D33D61 /* MainStoryboard_iPhone.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DD582BAB150110E600D33D61 /* MainStoryboard_iPhone.storyboard */; };
+ DD582BB0150110E600D33D61 /* MainStoryboard_iPad.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DD582BAE150110E600D33D61 /* MainStoryboard_iPad.storyboard */; };
+ DD582BB3150110E600D33D61 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DD582BB2150110E600D33D61 /* ViewController.m */; };
+ DD582BBB1501112D00D33D61 /* LoadImage.m in Sources */ = {isa = PBXBuildFile; fileRef = DD582BBA1501112D00D33D61 /* LoadImage.m */; };
+ DD582BBD1501131A00D33D61 /* apple_logo.pdf in Resources */ = {isa = PBXBuildFile; fileRef = DD582BBC1501131A00D33D61 /* apple_logo.pdf */; };
+ DD582BC81501148F00D33D61 /* NSThread+Blocks.m in Sources */ = {isa = PBXBuildFile; fileRef = DD582BC71501148F00D33D61 /* NSThread+Blocks.m */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ DD582B95150110E600D33D61 /* AssetsFromPDF.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AssetsFromPDF.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ DD582B99150110E600D33D61 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ DD582B9B150110E600D33D61 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ DD582B9D150110E600D33D61 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ DD582BA1150110E600D33D61 /* AssetsFromPDF-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "AssetsFromPDF-Info.plist"; sourceTree = "<group>"; };
+ DD582BA3150110E600D33D61 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ DD582BA5150110E600D33D61 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ DD582BA7150110E600D33D61 /* AssetsFromPDF-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "AssetsFromPDF-Prefix.pch"; sourceTree = "<group>"; };
+ DD582BA8150110E600D33D61 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
+ DD582BA9150110E600D33D61 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
+ DD582BAC150110E600D33D61 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPhone.storyboard; sourceTree = "<group>"; };
+ DD582BAF150110E600D33D61 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = en; path = en.lproj/MainStoryboard_iPad.storyboard; sourceTree = "<group>"; };
+ DD582BB1150110E600D33D61 /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
+ DD582BB2150110E600D33D61 /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = "<group>"; };
+ DD582BB91501112D00D33D61 /* LoadImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadImage.h; sourceTree = "<group>"; };
+ DD582BBA1501112D00D33D61 /* LoadImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoadImage.m; sourceTree = "<group>"; };
+ DD582BBC1501131A00D33D61 /* apple_logo.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = apple_logo.pdf; sourceTree = "<group>"; };
+ DD582BC61501148F00D33D61 /* NSThread+Blocks.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSThread+Blocks.h"; sourceTree = "<group>"; };
+ DD582BC71501148F00D33D61 /* NSThread+Blocks.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSThread+Blocks.m"; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ DD582B92150110E600D33D61 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DD582B9A150110E600D33D61 /* UIKit.framework in Frameworks */,
+ DD582B9C150110E600D33D61 /* Foundation.framework in Frameworks */,
+ DD582B9E150110E600D33D61 /* CoreGraphics.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ DD582B8A150110E600D33D61 = {
+ isa = PBXGroup;
+ children = (
+ DD582B9F150110E600D33D61 /* AssetsFromPDF */,
+ DD582B98150110E600D33D61 /* Frameworks */,
+ DD582B96150110E600D33D61 /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ DD582B96150110E600D33D61 /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ DD582B95150110E600D33D61 /* AssetsFromPDF.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ DD582B98150110E600D33D61 /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ DD582B99150110E600D33D61 /* UIKit.framework */,
+ DD582B9B150110E600D33D61 /* Foundation.framework */,
+ DD582B9D150110E600D33D61 /* CoreGraphics.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ DD582B9F150110E600D33D61 /* AssetsFromPDF */ = {
+ isa = PBXGroup;
+ children = (
+ DD582BB91501112D00D33D61 /* LoadImage.h */,
+ DD582BBA1501112D00D33D61 /* LoadImage.m */,
+ DD582BBC1501131A00D33D61 /* apple_logo.pdf */,
+ DD582BC61501148F00D33D61 /* NSThread+Blocks.h */,
+ DD582BC71501148F00D33D61 /* NSThread+Blocks.m */,
+ DD582BA8150110E600D33D61 /* AppDelegate.h */,
+ DD582BA9150110E600D33D61 /* AppDelegate.m */,
+ DD582BAB150110E600D33D61 /* MainStoryboard_iPhone.storyboard */,
+ DD582BAE150110E600D33D61 /* MainStoryboard_iPad.storyboard */,
+ DD582BB1150110E600D33D61 /* ViewController.h */,
+ DD582BB2150110E600D33D61 /* ViewController.m */,
+ DD582BA0150110E600D33D61 /* Supporting Files */,
+ );
+ path = AssetsFromPDF;
+ sourceTree = "<group>";
+ };
+ DD582BA0150110E600D33D61 /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ DD582BA1150110E600D33D61 /* AssetsFromPDF-Info.plist */,
+ DD582BA2150110E600D33D61 /* InfoPlist.strings */,
+ DD582BA5150110E600D33D61 /* main.m */,
+ DD582BA7150110E600D33D61 /* AssetsFromPDF-Prefix.pch */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ DD582B94150110E600D33D61 /* AssetsFromPDF */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = DD582BB6150110E600D33D61 /* Build configuration list for PBXNativeTarget "AssetsFromPDF" */;
+ buildPhases = (
+ DD582B91150110E600D33D61 /* Sources */,
+ DD582B92150110E600D33D61 /* Frameworks */,
+ DD582B93150110E600D33D61 /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = AssetsFromPDF;
+ productName = AssetsFromPDF;
+ productReference = DD582B95150110E600D33D61 /* AssetsFromPDF.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ DD582B8C150110E600D33D61 /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ LastUpgradeCheck = 0440;
+ ORGANIZATIONNAME = "SpeakFeel Corporation";
+ };
+ buildConfigurationList = DD582B8F150110E600D33D61 /* Build configuration list for PBXProject "AssetsFromPDF" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = DD582B8A150110E600D33D61;
+ productRefGroup = DD582B96150110E600D33D61 /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ DD582B94150110E600D33D61 /* AssetsFromPDF */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ DD582B93150110E600D33D61 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DD582BA4150110E600D33D61 /* InfoPlist.strings in Resources */,
+ DD582BAD150110E600D33D61 /* MainStoryboard_iPhone.storyboard in Resources */,
+ DD582BB0150110E600D33D61 /* MainStoryboard_iPad.storyboard in Resources */,
+ DD582BBD1501131A00D33D61 /* apple_logo.pdf in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ DD582B91150110E600D33D61 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DD582BA6150110E600D33D61 /* main.m in Sources */,
+ DD582BAA150110E600D33D61 /* AppDelegate.m in Sources */,
+ DD582BB3150110E600D33D61 /* ViewController.m in Sources */,
+ DD582BBB1501112D00D33D61 /* LoadImage.m in Sources */,
+ DD582BC81501148F00D33D61 /* NSThread+Blocks.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ DD582BA2150110E600D33D61 /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ DD582BA3150110E600D33D61 /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+ DD582BAB150110E600D33D61 /* MainStoryboard_iPhone.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ DD582BAC150110E600D33D61 /* en */,
+ );
+ name = MainStoryboard_iPhone.storyboard;
+ sourceTree = "<group>";
+ };
+ DD582BAE150110E600D33D61 /* MainStoryboard_iPad.storyboard */ = {
+ isa = PBXVariantGroup;
+ children = (
+ DD582BAF150110E600D33D61 /* en */,
+ );
+ name = MainStoryboard_iPad.storyboard;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ DD582BB4150110E600D33D61 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ };
+ name = Debug;
+ };
+ DD582BB5150110E600D33D61 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.0;
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ SDKROOT = iphoneos;
+ TARGETED_DEVICE_FAMILY = "1,2";
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ DD582BB7150110E600D33D61 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "AssetsFromPDF/AssetsFromPDF-Prefix.pch";
+ INFOPLIST_FILE = "AssetsFromPDF/AssetsFromPDF-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ DD582BB8150110E600D33D61 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "AssetsFromPDF/AssetsFromPDF-Prefix.pch";
+ INFOPLIST_FILE = "AssetsFromPDF/AssetsFromPDF-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ DD582B8F150110E600D33D61 /* Build configuration list for PBXProject "AssetsFromPDF" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ DD582BB4150110E600D33D61 /* Debug */,
+ DD582BB5150110E600D33D61 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ DD582BB6150110E600D33D61 /* Build configuration list for PBXNativeTarget "AssetsFromPDF" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ DD582BB7150110E600D33D61 /* Debug */,
+ DD582BB8150110E600D33D61 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = DD582B8C150110E600D33D61 /* Project object */;
+}
15 AssetsFromPDF/AppDelegate.h
@@ -0,0 +1,15 @@
+//
+// AppDelegate.h
+// AssetsFromPDF
+//
+// Created by Jeffrey Sambells on 2012-03-02.
+// Copyright (c) 2012 SpeakFeel Corporation. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface AppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+
+@end
48 AssetsFromPDF/AppDelegate.m
@@ -0,0 +1,48 @@
+//
+// AppDelegate.m
+// AssetsFromPDF
+//
+// Created by Jeffrey Sambells on 2012-03-02.
+// Copyright (c) 2012 SpeakFeel Corporation. All rights reserved.
+//
+
+#import "AppDelegate.h"
+
+@implementation AppDelegate
+
+@synthesize window = _window;
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ // Override point for customization after application launch.
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application
+{
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application
+{
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application
+{
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+}
+
+@end
49 AssetsFromPDF/AssetsFromPDF-Info.plist
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.tropicalpixels.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UIMainStoryboardFile</key>
+ <string>MainStoryboard_iPhone</string>
+ <key>UIMainStoryboardFile~ipad</key>
+ <string>MainStoryboard_iPad</string>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+ <key>UISupportedInterfaceOrientations~ipad</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationPortraitUpsideDown</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
14 AssetsFromPDF/AssetsFromPDF-Prefix.pch
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'AssetsFromPDF' target in the 'AssetsFromPDF' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_5_0
+#warning "This project uses features only available in iOS SDK 5.0 and later."
+#endif
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+#endif
14 AssetsFromPDF/LoadImage.h
@@ -0,0 +1,14 @@
+//
+// LoadImage.h
+// AssetsFromPDF
+//
+// Created by Jeffrey Sambells on 2012-03-02.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface LoadImage : NSObject
+
++ (void)LoadFromPDF:(NSString *)fileNameWithoutExtension size:(CGSize)size callback:(void (^)(UIImage *))callback;
+
+@end
103 AssetsFromPDF/LoadImage.m
@@ -0,0 +1,103 @@
+//
+// LoadImage.m
+// AssetsFromPDF
+//
+// Created by Jeffrey Sambells on 2012-03-02.
+//
+
+#import "LoadImage.h"
+#import "NSThread+Blocks.h"
+
+@implementation LoadImage
+
++ (void)LoadFromPDF:(NSString *)fileNameWithoutExtension size:(CGSize)size callback:(void (^)(UIImage *))callback {
+
+ [NSThread performBlockInBackground:^{
+
+
+ // Determine if the device is retina.
+ BOOL isRetina = [UIScreen instancesRespondToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2.0;
+
+
+ // Create a file manager so we can check if the image exists and store the image.
+ NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
+ NSString *documentsDirectory = [paths objectAtIndex:0];
+ NSFileManager *fileManger = [NSFileManager defaultManager];
+
+ // Define the formats for the image names (low and high res).
+ NSString *path = @"rendered-%@.png";
+ NSString *pathHigh = @"rendered-%@@2x.png";
+
+ // Get the file name.
+ NSString *file = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:( isRetina ? pathHigh : path ) , fileNameWithoutExtension]];
+
+ UIImage *image;
+
+ if ( ![fileManger fileExistsAtPath:file] ) {
+
+ // Image doesn't exist so load the PDF and create it.
+
+ // Get a reference to the PDF.
+ NSString *pdfName = [NSString stringWithFormat:@"%@.pdf", fileNameWithoutExtension];
+ CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), (__bridge CFStringRef)pdfName, NULL, NULL);
+ CGPDFDocumentRef pdfDoc = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
+ CFRelease(pdfURL);
+
+ if (isRetina) {
+ UIGraphicsBeginImageContextWithOptions(size, false, 0);
+ } else {
+ UIGraphicsBeginImageContext( size );
+ }
+
+ // Load the first page. You could have multiple pages if you wanted.
+ CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfDoc, 1);
+
+ CGContextRef context = UIGraphicsGetCurrentContext();
+
+ // PDF page drawing expects a lower-left coordinate system,
+ // flip the coordinate system before we start drawing.
+ CGRect bounds = CGContextGetClipBoundingBox(context);
+ CGContextTranslateCTM(context, 0, bounds.size.height);
+ CGContextScaleCTM(context, 1.0, -1.0);
+
+ // Save the graphics state.
+ CGContextSaveGState(context);
+
+ // CGPDFPageGetDrawingTransform provides an easy way to get the transform
+ // for a PDF page. It will scale down to fit, including any
+ // base rotations necessary to display the PDF page correctly.
+ CGRect transformRect = CGRectMake(0, 0, size.width, size.height);
+ CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(pdfPage, kCGPDFCropBox, transformRect, 0, true);
+
+ // And apply the transform.
+ CGContextConcatCTM(context, pdfTransform);
+
+ // Draw the page.
+ CGContextDrawPDFPage(context, pdfPage);
+
+ // Restore the graphics state.
+ CGContextRestoreGState(context);
+
+ // Generate the image.
+ image = UIGraphicsGetImageFromCurrentImageContext();
+
+ // Store the PNG for next time.
+ [UIImagePNGRepresentation(image) writeToFile:file atomically:YES];
+
+ UIGraphicsEndImageContext();
+ CGPDFDocumentRelease(pdfDoc);
+
+ } else {
+
+ // Load the image from the file system.
+ image = [UIImage imageWithContentsOfFile:file];
+
+ }
+
+ [[NSThread mainThread] performBlock:^{
+ callback(image);
+ }];
+
+ }];}
+
+@end
11 AssetsFromPDF/NSThread+Blocks.h
@@ -0,0 +1,11 @@
+//
+// NSThread+Blocks.h
+//
+
+#import <Foundation/Foundation.h>
+
+@interface NSThread (BlocksAdditions)
+- (void)performBlock:(void (^)())block;
+- (void)performBlock:(void (^)())block waitUntilDone:(BOOL)wait;
++ (void)performBlockInBackground:(void (^)())block;
+@end
43 AssetsFromPDF/NSThread+Blocks.m
@@ -0,0 +1,43 @@
+//
+// NSThread+Blocks.m
+//
+
+#import "NSThread+Blocks.h"
+
+@implementation NSThread (BlocksAdditions)
+
+- (void)performBlock:(void (^)())block
+{
+ if ([[NSThread currentThread] isEqual:self])
+ block();
+ else
+ [self performBlock:block waitUntilDone:NO];
+}
+
+- (void)performBlock:(void (^)())block waitUntilDone:(BOOL)wait
+{
+ [NSThread performSelector:@selector(ng_runBlock:)
+ onThread:self
+ withObject:[block copy]
+ waitUntilDone:wait];
+}
+
++ (void)ng_runBlockPool:(void (^)())block
+{
+ @autoreleasepool {
+ block();
+ }
+}
+
++ (void)ng_runBlock:(void (^)())block
+{
+ block();
+}
+
++ (void)performBlockInBackground:(void (^)())block
+{
+ [NSThread performSelectorInBackground:@selector(ng_runBlockPool:)
+ withObject:[block copy]];
+}
+
+@end
13 AssetsFromPDF/ViewController.h
@@ -0,0 +1,13 @@
+//
+// ViewController.h
+// AssetsFromPDF
+//
+// Created by Jeffrey Sambells on 2012-03-02.
+// Copyright (c) 2012 SpeakFeel Corporation. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface ViewController : UIViewController
+
+@end
46 AssetsFromPDF/ViewController.m
@@ -0,0 +1,46 @@
+//
+// ViewController.m
+//
+// Created by Jeffrey Sambells on 2012-03-02.
+//
+
+#import "ViewController.h"
+#import "LoadImage.h"
+
+@interface ViewController ()
+
+@end
+
+@implementation ViewController
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ // Do any additional setup after loading the view, typically from a nib.
+
+ UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.frame];
+ [imageView setContentMode:UIViewContentModeCenter];
+ [self.view addSubview:imageView];
+
+ [LoadImage LoadFromPDF:@"apple_logo" size:CGSizeMake(100.0f,100.0f) callback:^(UIImage *image){
+ [imageView setImage:image];
+ }];
+
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
+ return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
+ } else {
+ return YES;
+ }
+}
+
+@end
BIN AssetsFromPDF/apple_logo.pdf
Binary file not shown.
2 AssetsFromPDF/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
27 AssetsFromPDF/en.lproj/MainStoryboard_iPad.storyboard
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.0" toolsVersion="1906" systemVersion="11A511" targetRuntime="iOS.CocoaTouch.iPad" nextObjectID="6" propertyAccessControl="none" initialViewController="2">
+ <dependencies>
+ <development defaultVersion="4200" identifier="xcode"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="902"/>
+ </dependencies>
+ <scenes>
+ <scene sceneID="4">
+ <objects>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="3" sceneMemberID="firstResponder"/>
+ <viewController id="2" customClass="ViewController" sceneMemberID="viewController">
+ <view key="view" contentMode="scaleToFill" id="5">
+ <rect key="frame" x="0.0" y="20" width="768" height="1004"/>
+ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+ <subviews/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ </view>
+ </viewController>
+ </objects>
+ </scene>
+ </scenes>
+ <simulatedMetricsContainer key="defaultSimulatedMetrics">
+ <simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackTranslucent"/>
+ <simulatedOrientationMetrics key="orientation"/>
+ <simulatedScreenMetrics key="destination"/>
+ </simulatedMetricsContainer>
+</document>
27 AssetsFromPDF/en.lproj/MainStoryboard_iPhone.storyboard
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="1.0" toolsVersion="1906" systemVersion="11A511" targetRuntime="iOS.CocoaTouch" nextObjectID="6" propertyAccessControl="none" initialViewController="2">
+ <dependencies>
+ <development defaultVersion="4200" identifier="xcode"/>
+ <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="902"/>
+ </dependencies>
+ <scenes>
+ <scene sceneID="5">
+ <objects>
+ <placeholder placeholderIdentifier="IBFirstResponder" id="4" sceneMemberID="firstResponder"/>
+ <viewController id="2" customClass="ViewController" sceneMemberID="viewController">
+ <view key="view" contentMode="scaleToFill" id="3">
+ <rect key="frame" x="0.0" y="20" width="320" height="460"/>
+ <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+ <subviews/>
+ <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
+ </view>
+ </viewController>
+ </objects>
+ </scene>
+ </scenes>
+ <simulatedMetricsContainer key="defaultSimulatedMetrics">
+ <simulatedStatusBarMetrics key="statusBar"/>
+ <simulatedOrientationMetrics key="orientation"/>
+ <simulatedScreenMetrics key="destination"/>
+ </simulatedMetricsContainer>
+</document>
18 AssetsFromPDF/main.m
@@ -0,0 +1,18 @@
+//
+// main.m
+// AssetsFromPDF
+//
+// Created by Jeffrey Sambells on 2012-03-02.
+// Copyright (c) 2012 SpeakFeel Corporation. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#import "AppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
+ }
+}

0 comments on commit e341ecd

Please sign in to comment.
Something went wrong with that request. Please try again.