Trying to repair C02

This commit is contained in:
Erica Sadun
2013-03-06 15:00:31 -07:00
parent edd56bc1c8
commit e8b3dad10c
333 changed files with 8111 additions and 7 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

View File

Before

Width:  |  Height:  |  Size: 223 KiB

After

Width:  |  Height:  |  Size: 223 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,329 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
8E8E4A5715EBCB3000172C67 /* UTIHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E8E4A5615EBCB3000172C67 /* UTIHelper.m */; };
8E8E4A5D15EBCD3400172C67 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E8E4A5C15EBCD3400172C67 /* MobileCoreServices.framework */; };
8E8E4A6015EBD04200172C67 /* MIMEHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E8E4A5F15EBD04200172C67 /* MIMEHelper.m */; };
8EA6B98315EFBDAE00BAD380 /* ApacheMIMETypes.txt in Resources */ = {isa = PBXBuildFile; fileRef = 8EA6B98215EFBDAE00BAD380 /* ApacheMIMETypes.txt */; };
8EB9BF0E158B9B4800F96828 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF0D158B9B4800F96828 /* Icon.png */; };
8EB9BF19158B9B7900F96828 /* Default-Landscape@2x~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF10158B9B7900F96828 /* Default-Landscape@2x~ipad.png */; };
8EB9BF1A158B9B7900F96828 /* Default-Landscape~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF11158B9B7900F96828 /* Default-Landscape~ipad.png */; };
8EB9BF1B158B9B7900F96828 /* Default-Portrait@2x~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF12158B9B7900F96828 /* Default-Portrait@2x~ipad.png */; };
8EB9BF1C158B9B7900F96828 /* Default-Portrait~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF13158B9B7900F96828 /* Default-Portrait~ipad.png */; };
8EB9BF1D158B9B7900F96828 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF14158B9B7900F96828 /* Default.png */; };
8EB9BF1E158B9B7900F96828 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF15158B9B7900F96828 /* Default@2x.png */; };
8EB9BF1F158B9B7900F96828 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF16158B9B7900F96828 /* Icon@2x.png */; };
8EB9BF20158B9B7900F96828 /* Icon~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF17158B9B7900F96828 /* Icon~ipad.png */; };
8EB9BF21158B9B7900F96828 /* Icon~ipad@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF18158B9B7900F96828 /* Icon~ipad@2x.png */; };
8EE7D0F515D843680026D7B9 /* Notes in Resources */ = {isa = PBXBuildFile; fileRef = 8EE7D0F415D843680026D7B9 /* Notes */; };
8EF624E115892BA600A81FD2 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EF624E015892BA600A81FD2 /* UIKit.framework */; };
8EF624E315892BA600A81FD2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EF624E215892BA600A81FD2 /* Foundation.framework */; };
8EF624E515892BA600A81FD2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EF624E415892BA600A81FD2 /* CoreGraphics.framework */; };
8EF624EB15892BA600A81FD2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8EF624E915892BA600A81FD2 /* InfoPlist.strings */; };
8EF624ED15892BA600A81FD2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EF624EC15892BA600A81FD2 /* main.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
8E8E4A5515EBCB3000172C67 /* UTIHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTIHelper.h; sourceTree = "<group>"; };
8E8E4A5615EBCB3000172C67 /* UTIHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UTIHelper.m; sourceTree = "<group>"; };
8E8E4A5C15EBCD3400172C67 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
8E8E4A5E15EBD04200172C67 /* MIMEHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MIMEHelper.h; sourceTree = "<group>"; };
8E8E4A5F15EBD04200172C67 /* MIMEHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MIMEHelper.m; sourceTree = "<group>"; };
8EA6B98215EFBDAE00BAD380 /* ApacheMIMETypes.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ApacheMIMETypes.txt; sourceTree = "<group>"; };
8EB9BF0D158B9B4800F96828 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon.png; path = AppArt/Icon.png; sourceTree = "<group>"; };
8EB9BF10158B9B7900F96828 /* Default-Landscape@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Landscape@2x~ipad.png"; path = "AppArt/Default-Landscape@2x~ipad.png"; sourceTree = "<group>"; };
8EB9BF11158B9B7900F96828 /* Default-Landscape~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Landscape~ipad.png"; path = "AppArt/Default-Landscape~ipad.png"; sourceTree = "<group>"; };
8EB9BF12158B9B7900F96828 /* Default-Portrait@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Portrait@2x~ipad.png"; path = "AppArt/Default-Portrait@2x~ipad.png"; sourceTree = "<group>"; };
8EB9BF13158B9B7900F96828 /* Default-Portrait~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Portrait~ipad.png"; path = "AppArt/Default-Portrait~ipad.png"; sourceTree = "<group>"; };
8EB9BF14158B9B7900F96828 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = AppArt/Default.png; sourceTree = "<group>"; };
8EB9BF15158B9B7900F96828 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "AppArt/Default@2x.png"; sourceTree = "<group>"; };
8EB9BF16158B9B7900F96828 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon@2x.png"; path = "AppArt/Icon@2x.png"; sourceTree = "<group>"; };
8EB9BF17158B9B7900F96828 /* Icon~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon~ipad.png"; path = "AppArt/Icon~ipad.png"; sourceTree = "<group>"; };
8EB9BF18158B9B7900F96828 /* Icon~ipad@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon~ipad@2x.png"; path = "AppArt/Icon~ipad@2x.png"; sourceTree = "<group>"; };
8EE7D0F415D843680026D7B9 /* Notes */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Notes; sourceTree = "<group>"; };
8EE9B88F15B746C400F4FCCA /* Utility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Utility.h; sourceTree = "<group>"; };
8EF624DC15892BA600A81FD2 /* HelloWorld.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorld.app; sourceTree = BUILT_PRODUCTS_DIR; };
8EF624E015892BA600A81FD2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
8EF624E215892BA600A81FD2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
8EF624E415892BA600A81FD2 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
8EF624E815892BA600A81FD2 /* HelloWorld-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HelloWorld-Info.plist"; sourceTree = "<group>"; };
8EF624EA15892BA600A81FD2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
8EF624EC15892BA600A81FD2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = main.m; path = HelloWorld/main.m; sourceTree = "<group>"; };
8EF624EE15892BA600A81FD2 /* HelloWorld-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "HelloWorld-Prefix.pch"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8EF624D915892BA600A81FD2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8E8E4A5D15EBCD3400172C67 /* MobileCoreServices.framework in Frameworks */,
8EF624E115892BA600A81FD2 /* UIKit.framework in Frameworks */,
8EF624E315892BA600A81FD2 /* Foundation.framework in Frameworks */,
8EF624E515892BA600A81FD2 /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
8EF624D115892BA600A81FD2 = {
isa = PBXGroup;
children = (
8EF624EC15892BA600A81FD2 /* main.m */,
8E8E4A5515EBCB3000172C67 /* UTIHelper.h */,
8E8E4A5615EBCB3000172C67 /* UTIHelper.m */,
8E8E4A5E15EBD04200172C67 /* MIMEHelper.h */,
8E8E4A5F15EBD04200172C67 /* MIMEHelper.m */,
8EA6B98215EFBDAE00BAD380 /* ApacheMIMETypes.txt */,
8EF624E715892BA600A81FD2 /* Supporting Files */,
8EF624DF15892BA600A81FD2 /* Frameworks */,
8EF624DD15892BA600A81FD2 /* Products */,
);
sourceTree = "<group>";
};
8EF624DD15892BA600A81FD2 /* Products */ = {
isa = PBXGroup;
children = (
8EF624DC15892BA600A81FD2 /* HelloWorld.app */,
);
name = Products;
sourceTree = "<group>";
};
8EF624DF15892BA600A81FD2 /* Frameworks */ = {
isa = PBXGroup;
children = (
8E8E4A5C15EBCD3400172C67 /* MobileCoreServices.framework */,
8EF624E015892BA600A81FD2 /* UIKit.framework */,
8EF624E215892BA600A81FD2 /* Foundation.framework */,
8EF624E415892BA600A81FD2 /* CoreGraphics.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
8EF624E715892BA600A81FD2 /* Supporting Files */ = {
isa = PBXGroup;
children = (
8EE9B88F15B746C400F4FCCA /* Utility.h */,
8EE7D0F415D843680026D7B9 /* Notes */,
8EF6250B15892CDA00A81FD2 /* System Art */,
8EF624E815892BA600A81FD2 /* HelloWorld-Info.plist */,
8EF624E915892BA600A81FD2 /* InfoPlist.strings */,
8EF624EE15892BA600A81FD2 /* HelloWorld-Prefix.pch */,
);
name = "Supporting Files";
path = HelloWorld;
sourceTree = "<group>";
};
8EF6250B15892CDA00A81FD2 /* System Art */ = {
isa = PBXGroup;
children = (
8EB9BF0D158B9B4800F96828 /* Icon.png */,
8EB9BF10158B9B7900F96828 /* Default-Landscape@2x~ipad.png */,
8EB9BF11158B9B7900F96828 /* Default-Landscape~ipad.png */,
8EB9BF12158B9B7900F96828 /* Default-Portrait@2x~ipad.png */,
8EB9BF13158B9B7900F96828 /* Default-Portrait~ipad.png */,
8EB9BF14158B9B7900F96828 /* Default.png */,
8EB9BF15158B9B7900F96828 /* Default@2x.png */,
8EB9BF16158B9B7900F96828 /* Icon@2x.png */,
8EB9BF17158B9B7900F96828 /* Icon~ipad.png */,
8EB9BF18158B9B7900F96828 /* Icon~ipad@2x.png */,
);
name = "System Art";
path = ..;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
8EF624DB15892BA600A81FD2 /* HelloWorld */ = {
isa = PBXNativeTarget;
buildConfigurationList = 8EF624F415892BA600A81FD2 /* Build configuration list for PBXNativeTarget "HelloWorld" */;
buildPhases = (
8EF624D815892BA600A81FD2 /* Sources */,
8EF624D915892BA600A81FD2 /* Frameworks */,
8EF624DA15892BA600A81FD2 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = HelloWorld;
productName = HelloWorld;
productReference = 8EF624DC15892BA600A81FD2 /* HelloWorld.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
8EF624D315892BA600A81FD2 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0450;
ORGANIZATIONNAME = "Erica Sadun";
};
buildConfigurationList = 8EF624D615892BA600A81FD2 /* Build configuration list for PBXProject "HelloWorld" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 8EF624D115892BA600A81FD2;
productRefGroup = 8EF624DD15892BA600A81FD2 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
8EF624DB15892BA600A81FD2 /* HelloWorld */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
8EF624DA15892BA600A81FD2 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8EF624EB15892BA600A81FD2 /* InfoPlist.strings in Resources */,
8EB9BF0E158B9B4800F96828 /* Icon.png in Resources */,
8EB9BF19158B9B7900F96828 /* Default-Landscape@2x~ipad.png in Resources */,
8EB9BF1A158B9B7900F96828 /* Default-Landscape~ipad.png in Resources */,
8EB9BF1B158B9B7900F96828 /* Default-Portrait@2x~ipad.png in Resources */,
8EB9BF1C158B9B7900F96828 /* Default-Portrait~ipad.png in Resources */,
8EB9BF1D158B9B7900F96828 /* Default.png in Resources */,
8EB9BF1E158B9B7900F96828 /* Default@2x.png in Resources */,
8EB9BF1F158B9B7900F96828 /* Icon@2x.png in Resources */,
8EB9BF20158B9B7900F96828 /* Icon~ipad.png in Resources */,
8EB9BF21158B9B7900F96828 /* Icon~ipad@2x.png in Resources */,
8EE7D0F515D843680026D7B9 /* Notes in Resources */,
8EA6B98315EFBDAE00BAD380 /* ApacheMIMETypes.txt in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
8EF624D815892BA600A81FD2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8EF624ED15892BA600A81FD2 /* main.m in Sources */,
8E8E4A5715EBCB3000172C67 /* UTIHelper.m in Sources */,
8E8E4A6015EBD04200172C67 /* MIMEHelper.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
8EF624E915892BA600A81FD2 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
8EF624EA15892BA600A81FD2 /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
8EF624F215892BA600A81FD2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = 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_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
8EF624F315892BA600A81FD2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
8EF624F515892BA600A81FD2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "HelloWorld/HelloWorld-Prefix.pch";
INFOPLIST_FILE = "HelloWorld/HelloWorld-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
8EF624F615892BA600A81FD2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "HelloWorld/HelloWorld-Prefix.pch";
INFOPLIST_FILE = "HelloWorld/HelloWorld-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
8EF624D615892BA600A81FD2 /* Build configuration list for PBXProject "HelloWorld" */ = {
isa = XCConfigurationList;
buildConfigurations = (
8EF624F215892BA600A81FD2 /* Debug */,
8EF624F315892BA600A81FD2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
8EF624F415892BA600A81FD2 /* Build configuration list for PBXNativeTarget "HelloWorld" */ = {
isa = XCConfigurationList;
buildConfigurations = (
8EF624F515892BA600A81FD2 /* Debug */,
8EF624F615892BA600A81FD2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 8EF624D315892BA600A81FD2 /* Project object */;
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "1.0">
</Bucket>

View File

@@ -0,0 +1,65 @@
<?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>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Icon.png</string>
<string>Icon@2x.png</string>
<string>Default.png</string>
<string>Default@2x.png</string>
<string>Icon~ipad.png</string>
<string>Icon~ipad@2x.png</string>
<string>Default-Portrait~ipad.png</string>
<string>Default-Portrait@2x~ipad.png</string>
<string>Default-Landscape~ipad.png</string>
<string>Default-Landscape@2x~ipad.png</string>
</array>
</dict>
</dict>
<key>CFBundleIdentifier</key>
<string>com.sadun.${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>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>

View File

@@ -0,0 +1,106 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#pragma mark - Cookbook
#define COOKBOOK_PURPLE_COLOR [UIColor colorWithRed:0.20392f green:0.19607f blue:0.61176f alpha:1.0f]
#pragma mark - Bar Buttons
#define BARBUTTON(TITLE, SELECTOR) [[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self action:SELECTOR]
#define SYSBARBUTTON(ITEM, SELECTOR) [[UIBarButtonItem alloc] initWithBarButtonSystemItem:ITEM target:self action:SELECTOR]
#define IMGBARBUTTON(IMAGE, SELECTOR) [[UIBarButtonItem alloc] initWithImage:IMAGE style:UIBarButtonItemStylePlain target:self action:SELECTOR]
#define CUSTOMBARBUTTON(VIEW) [[UIBarButtonItem alloc] initWithCustomView:VIEW]
#define SYSBARBUTTON_TARGET(ITEM, TARGET, SELECTOR) [[UIBarButtonItem alloc] initWithBarButtonSystemItem:ITEM target:TARGET action:SELECTOR]
#define BARBUTTON_TARGET(TITLE, TARGET, SELECTOR) [[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:TARGET action:SELECTOR]
#pragma mark - Platform
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#pragma mark - Orientation
// #define IS_PORTRAIT UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)
// #define IS_PORTRAIT UIDeviceOrientationIsPortrait(self.interfaceOrientation)
// #define IS_PORTRAIT UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation) || UIDeviceOrientationIsPortrait(self.interfaceOrientation)
#pragma mark - Debug
#define BOOL_CHECK(TITLE, CHECK_ITEM) printf("%s: %s\n", TITLE, (CHECK_ITEM) ? "Yes" : "No")
#pragma mark - Geometry
#define RECTCENTER(RECT) CGPointMake(CGRectGetMidX(RECT), CGRectGetMidY(RECT))
#define RECT_PT(_X_, _Y_) CGRectMake(_X_, _Y_, 0.0f, 0.0f)
#define RECT_SIZE(_W_, _H_) CGRectMake(0.0f, 0.0f, _W_, _H_)
#pragma mark - Autosizing
#define RESIZABLE(VIEW) [VIEW setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth]
#pragma mark - Strings
#define STREQ(STRING1, STRING2) ([STRING1 caseInsensitiveCompare:STRING2] == NSOrderedSame)
#define PREFIXED(STRING1, STRING2) ([[STRING1 uppercaseString] hasPrefix:[STRING2 uppercaseString]])
#define TRIMSTRING(STRING) ([STRING stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]])
#define PADSTRING(STRING) ([NSString stringWithFormat:@" %@ ", TRIMSTRING(STRING)])
#define STRDATA(STRING) ([STRING dataUsingEncoding:NSUTF8StringEncoding])
#define DATASTR(DATA) ([[NSString alloc] initWithData:DATA encoding:NSUTF8StringEncoding])
#define RECTSTRING(_aRect_) NSStringFromCGRect(_aRect_)
#define POINTSTRING(_aPoint_) NSStringFromCGPoint(_aPoint_)
#define SIZESTRING(_aSize_) NSStringFromCGSize(_aSize_)
#pragma mark - Constraints
#define PREPCONSTRAINTS(VIEW) [VIEW setTranslatesAutoresizingMaskIntoConstraints:NO]
#define CONSTRAIN(PARENT, VIEW, FORMAT) [PARENT addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:(FORMAT) options:0 metrics:nil views:NSDictionaryOfVariableBindings(VIEW)]]
#define CONSTRAIN_VIEWS(PARENT, FORMAT, BINDINGS) [PARENT addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:(FORMAT) options:0 metrics:nil views:BINDINGS]]
// Stretch across axes
#define STRETCH_VIEW_H(PARENT, VIEW) CONSTRAIN(PARENT, VIEW, @"H:|["#VIEW"(>=0)]|")
#define STRETCH_VIEW_V(PARENT, VIEW) CONSTRAIN(PARENT, VIEW, @"V:|["#VIEW"(>=0)]|")
#define STRETCH_VIEW(PARENT, VIEW) {STRETCH_VIEW_H(PARENT, VIEW); STRETCH_VIEW_V(PARENT, VIEW);}
// Center along axes
#define CENTER_VIEW_H(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeCenterX multiplier:1.0f constant:0.0f]]
#define CENTER_VIEW_V(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeCenterY multiplier:1.0f constant:0.0f]]
#define CENTER_VIEW(PARENT, VIEW) {CENTER_VIEW_H(PARENT, VIEW); CENTER_VIEW_V(PARENT, VIEW);}
// Align to parent
#define ALIGN_VIEW_LEFT(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeLeft multiplier:1.0f constant:0.0f]]
#define ALIGN_VIEW_RIGHT(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeRight multiplier:1.0f constant:0.0f]]
#define ALIGN_VIEW_TOP(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeTop multiplier:1.0f constant:0.0f]]
#define ALIGN_VIEW_BOTTOM(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeBottom multiplier:1.0f constant:0.0f]]
// Set Size
#define CONSTRAIN_WIDTH(VIEW, WIDTH) CONSTRAIN(VIEW, VIEW, @"H:["#VIEW"(=="#WIDTH")]")
#define CONSTRAIN_HEIGHT(VIEW, HEIGHT) CONSTRAIN(VIEW, VIEW, @"V:["#VIEW"(=="#HEIGHT")]")
#define CONSTRAIN_SIZE(VIEW, HEIGHT, WIDTH) {CONSTRAIN_WIDTH(VIEW, WIDTH); CONSTRAIN_HEIGHT(VIEW, HEIGHT);}
// Set Aspect
#define CONSTRAIN_ASPECT(VIEW, ASPECT) [VIEW addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:VIEW attribute:NSLayoutAttributeHeight multiplier:(ASPECT) constant:0.0f]]
// Order items
#define CONSTRAIN_ORDER_H(PARENT, VIEW1, VIEW2) [PARENT addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:(@"H:["#VIEW1"]->=0-["#VIEW2"]") options:0 metrics:nil views:NSDictionaryOfVariableBindings(VIEW1, VIEW2)]]
#define CONSTRAIN_ORDER_V(PARENT, VIEW1, VIEW2) [PARENT addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:(@"V:["#VIEW1"]->=0-["#VIEW2"]") options:0 metrics:nil views:NSDictionaryOfVariableBindings(VIEW1, VIEW2)]]
#pragma mark - Defaults
// Defaults
#define DEFAULT_INT(_KEY_) [[NSUserDefaults standardUserDefaults] integerForKey:_KEY_]
#define DEFAULT_OBJ(_KEY_) [[NSUserDefaults standardUserDefaults] objectForKey:_KEY_]
#pragma mark - Util
// Bail with complaint
#define COMPLAIN_AND_BAIL(_COMPLAINT_, _ARG_) {NSLog(_COMPLAINT_, _ARG_); return;}
#define COMPLAIN_AND_BAIL_NIL(_COMPLAINT_, _ARG_) {NSLog(_COMPLAINT_, _ARG_); return nil;}
#pragma mark - Delegates and Controls
// Delegate
#define SAFE_PERFORM_WITH_ARG(THE_OBJECT, THE_SELECTOR, THE_ARG) (([THE_OBJECT respondsToSelector:THE_SELECTOR]) ? [THE_OBJECT performSelector:THE_SELECTOR withObject:THE_ARG] : nil)
// Controls
#define CALLBACK_VAL(_CONTROL_, _SELECTOR_) [_CONTROL_ addTarget:self action:_SELECTOR_ forControlEvents:UIControlEventValueChanged]
#define CALLBACK_PRESS(_CONTROL_, _SELECTOR_) [_CONTROL_ addTarget:self action:_SELECTOR_ forControlEvents:UIControlEventTouchUpInside]
#define SAFE_CALLBACK_VAL(_CONTROL_, _SELECTOR_) {if ([self respondsToSelector:_SELECTOR_]) CALLBACK_VAL(_CONTROL_, _SELECTOR_);}
#define SAFE_CALLBACK_PRESS(_CONTROL_, _SELECTOR_) {if ([self respondsToSelector:_SELECTOR_]) CALLBACK_PRESS(_CONTROL_, _SELECTOR_);}

View File

@@ -0,0 +1,107 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#import <UIKit/UIKit.h>
#import "Utility.h"
#import "UTIHelper.h"
#import "MIMEHelper.h"
#define VARIOUS_EXTENSIONS @[@"3dm",@"3dmf",@"a",@"aab",@"aam",@"aas",@"abc",@"acgi",@"afl",@"ai",@"aif",@"aifc",@"aiff",@"aim",@"aip",@"ani",@"aos",@"aps",@"arc",@"arj",@"art",@"asf",@"asm",@"asp",@"asx",@"au",@"avi",@"avs",@"bcpio",@"bin",@"bm",@"bmp",@"boo",@"book",@"boz",@"bsh",@"bz",@"bz2",@"c",@"c++",@"cat",@"cc",@"ccad",@"cco",@"cdf",@"cer",@"cha",@"chat",@"class",@"com",@"conf",@"cpio",@"cpp",@"cpt",@"crl",@"crt",@"csh",@"css",@"cxx",@"dcr",@"deepv",@"def",@"der",@"dif",@"dir",@"dl",@"doc",@"dot",@"dp",@"drw",@"dump",@"dv",@"dvi",@"dwf",@"dwg",@"dxf",@"dxr",@"el",@"elc",@"env",@"eps",@"es",@"etx",@"evy",@"exe",@"f",@"f77",@"f90",@"fdf",@"fif",@"fli",@"flo",@"flx",@"fmf",@"for",@"fpx",@"frl",@"funk",@"g",@"g3",@"gif",@"gl",@"gsd",@"gsm",@"gsp",@"gss",@"gtar",@"gz",@"gzip",@"h",@"hdf",@"help",@"hgl",@"hh",@"hlb",@"hlp",@"hpg",@"hpgl",@"hqx",@"hta",@"htc",@"htm",@"html",@"htmls",@"htt",@"htx",@"ice",@"ico",@"idc",@"ief",@"iefs",@"iges",@"igs",@"ima",@"imap",@"inf",@"ins",@"ip",@"isu",@"it",@"iv",@"ivr",@"ivy",@"jam",@"jav",@"java",@"jcm",@"jfif",@"jfif-tbnl",@"jpe",@"jpeg",@"jpg",@"thm",@"jpg",@"jps",@"js",@"jut",@"kar",@"ksh",@"la",@"lam",@"latex",@"lha",@"lhx",@"list",@"lma",@"log",@"lsp",@"lst",@"lsx",@"ltx",@"lzh",@"lzx",@"m",@"m1v",@"m2a",@"m2v",@"m3u",@"man",@"map",@"mar",@"mbd",@"mc$",@"mcd",@"mcf",@"mcp",@"me",@"mht",@"mhtml",@"mid",@"midi",@"mif",@"mime",@"mjf",@"mjpg",@"mm",@"mme",@"mod",@"moov",@"mov",@"movie",@"mp2",@"mp3",@"mpa",@"mpc",@"mpe",@"mpeg",@"mpg",@"mpga",@"mpp",@"mpt",@"mpv",@"mpx",@"mrc",@"ms",@"mv",@"my",@"mzz",@"nap",@"naplps",@"nc",@"ncm",@"nif",@"niff",@"nix",@"nsc",@"nvd",@"o",@"oda",@"omc",@"omcd",@"omcr",@"p",@"p10",@"p12",@"p7a",@"p7c",@"p7m",@"p7r",@"p7s",@"part",@"pas",@"pbm",@"pcl",@"pct",@"pcx",@"pdb",@"pdf",@"pfunk",@"pgm",@"pic",@"pict",@"pkg",@"pko",@"pl",@"plist",@"plx",@"pm",@"pm4",@"pm5",@"png",@"pnm",@"pot",@"pov",@"ppa",@"ppm",@"pps",@"ppt",@"ppz",@"pre",@"prt",@"ps",@"psd",@"pvu",@"pwz",@"py",@"pyc",@"qcp",@"qd3",@"qd3d",@"qif",@"qt",@"qtc",@"qti",@"qtif",@"ra",@"ram",@"ras",@"rast",@"rexx",@"rf",@"rgb",@"rm",@"rmi",@"rmm",@"rmp",@"rng",@"rnx",@"roff",@"rp",@"rpm",@"rt",@"rtf",@"rtx",@"rv",@"s",@"s3m",@"saveme",@"sbk",@"scm",@"sdml",@"sdp",@"sdr",@"sea",@"set",@"sgm",@"sgml",@"sh",@"shar",@"shtml",@"sid",@"sit",@"skd",@"skm",@"skp",@"skt",@"sl",@"smi",@"smil",@"snd",@"sol",@"spc",@"spl",@"spr",@"sprite",@"src",@"ssi",@"ssm",@"sst",@"step",@"stl",@"stp",@"sv4cpio",@"sv4crc",@"svf",@"svr",@"swf",@"t",@"talk",@"tar",@"tbk",@"tcl",@"tcsh",@"tex",@"texi",@"texinfo",@"text",@"tgz",@"tif",@"tiff",@"tr",@"tsi",@"tsp",@"tsv",@"turbot",@"txt",@"uil",@"uni",@"unis",@"unv",@"uri",@"uris",@"ustar",@"uu",@"uue",@"vcd",@"vcs",@"vda",@"vdo",@"vew",@"viv",@"vivo",@"vmd",@"vmf",@"voc",@"vos",@"vox",@"vqe",@"vqf",@"vql",@"vrml",@"vrt",@"vsd",@"vst",@"vsw",@"w60",@"w61",@"w6w",@"wav",@"wb1",@"wbmp",@"web",@"wiz",@"wk1",@"wmf",@"wml",@"wmlc",@"wmls",@"wmlsc",@"word",@"wp",@"wp5",@"wp6",@"wpd",@"wq1",@"wri",@"wrl",@"wrz",@"wsc",@"wsrc",@"wtk",@"xbm",@"xdr",@"xgz",@"xif",@"xl",@"xla",@"xlb",@"xlc",@"xld",@"xlk",@"xll",@"xlm",@"xls",@"xlt",@"xlv",@"xlw",@"xm",@"xml",@"xmz",@"xpix",@"xpm",@"x-png",@"xsr",@"xwd",@"xyz",@"z",@"zip",@"zoo",@"zsh"]
@interface TestBedViewController : UIViewController
@end
@implementation TestBedViewController
{
UITextView *textView;
NSMutableString *log;
}
- (void) doLog: (NSString *) formatstring, ...
{
if (!formatstring) return;
va_list arglist;
va_start(arglist, formatstring);
NSString *outstring = [[NSString alloc] initWithFormat:formatstring arguments:arglist];
va_end(arglist);
if (!log) log = [NSMutableString string];
NSLog(@"%@", outstring);
[log appendString:outstring];
[log appendString:@"\n"];
textView.text = log;
}
- (void) showExtensions
{
int count = 0; // total
int count1 = 0; // preferred MIME types
int count2 = 0; // Apache
for (NSString *ext in VARIOUS_EXTENSIONS)
{
NSString *uti = preferredUTIForExtension(ext);
NSString *mime1 = preferredMimeTypeForUTI(uti);
NSString *mime2 = mimeForExtension(ext); // Using Apache
// [self doLog:@"%@: %@ [%@] [%@]", ext, uti, mime1, mime2];
NSLog(@"%@: %@ [%@] [%@]", ext, uti, mime1, mime2);
count++;
if (mime1) count1++;
if (mime2) count2++;
}
[self doLog:@"Number of items: %d", count];
[self doLog:@"Preferred MIME types: %d", count1];
[self doLog:@"Apache: %d", count2];
}
- (void) loadView
{
[super loadView];
self.view.backgroundColor = [UIColor whiteColor];
self.navigationItem.leftBarButtonItem = BARBUTTON(@"Ext", @selector(showExtensions));
textView = [[UITextView alloc] init];
[self.view addSubview:textView];
PREPCONSTRAINTS(textView);
STRETCH_VIEW(self.view, textView);
textView.font = [UIFont fontWithName:@"Futura" size:18.0f];
textView.editable = NO;
}
@end
#pragma mark - Application Setup -
@interface TestBedAppDelegate : NSObject <UIApplicationDelegate>
@end
@implementation TestBedAppDelegate
{
UIWindow *window;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// [application setStatusBarHidden:YES];
[[UINavigationBar appearance] setTintColor:COOKBOOK_PURPLE_COLOR];
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
TestBedViewController *tbvc = [[TestBedViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:tbvc];
window.rootViewController = nav;
[window makeKeyAndVisible];
return YES;
}
@end
int main(int argc, char *argv[]) {
@autoreleasepool {
int retVal = UIApplicationMain(argc, argv, nil, @"TestBedAppDelegate");
return retVal;
}
}

View File

@@ -0,0 +1,659 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#import "MIMEHelper.h"
#define STRINGEQ(X,Y) ([X caseInsensitiveCompare:Y] == NSOrderedSame)
NSString *mimeForExtension(NSString *extension)
{
NSString *uc = [extension uppercaseString];
if(STRINGEQ(uc, @"3dm")) return @"x-world/x-3dmf";
if(STRINGEQ(uc, @"3dmf")) return @"x-world/x-3dmf";
if(STRINGEQ(uc, @"a")) return @"application/octet-stream";
if(STRINGEQ(uc, @"aab")) return @"application/x-authorware-bin";
if(STRINGEQ(uc, @"aam")) return @"application/x-authorware-map";
if(STRINGEQ(uc, @"aas")) return @"application/x-authorware-seg";
if(STRINGEQ(uc, @"abc")) return @"text/vnd.abc";
if(STRINGEQ(uc, @"acgi")) return @"text/html";
if(STRINGEQ(uc, @"afl")) return @"video/animaflex";
if(STRINGEQ(uc, @"ai")) return @"application/postscript";
if(STRINGEQ(uc, @"aif")) return @"audio/aiff";
if(STRINGEQ(uc, @"aif")) return @"audio/x-aiff";
if(STRINGEQ(uc, @"aifc")) return @"audio/aiff";
if(STRINGEQ(uc, @"aifc")) return @"audio/x-aiff";
if(STRINGEQ(uc, @"aiff")) return @"audio/aiff";
if(STRINGEQ(uc, @"aiff")) return @"audio/x-aiff";
if(STRINGEQ(uc, @"aim")) return @"application/x-aim";
if(STRINGEQ(uc, @"aip")) return @"text/x-audiosoft-intra";
if(STRINGEQ(uc, @"ani")) return @"application/x-navi-animation";
if(STRINGEQ(uc, @"aos")) return @"application/x-nokia-9000-communicator-add-on-software";
if(STRINGEQ(uc, @"aps")) return @"application/mime";
if(STRINGEQ(uc, @"arc")) return @"application/octet-stream";
if(STRINGEQ(uc, @"arj")) return @"application/arj";
if(STRINGEQ(uc, @"arj")) return @"application/octet-stream";
if(STRINGEQ(uc, @"art")) return @"image/x-jg";
if(STRINGEQ(uc, @"asf")) return @"video/x-ms-asf";
if(STRINGEQ(uc, @"asm")) return @"text/x-asm";
if(STRINGEQ(uc, @"asp")) return @"text/asp";
if(STRINGEQ(uc, @"asx")) return @"application/x-mplayer2";
if(STRINGEQ(uc, @"asx")) return @"video/x-ms-asf";
if(STRINGEQ(uc, @"asx")) return @"video/x-ms-asf-plugin";
if(STRINGEQ(uc, @"au")) return @"audio/basic";
if(STRINGEQ(uc, @"au")) return @"audio/x-au";
if(STRINGEQ(uc, @"avi")) return @"application/x-troff-msvideo";
if(STRINGEQ(uc, @"avi")) return @"video/avi";
if(STRINGEQ(uc, @"avi")) return @"video/msvideo";
if(STRINGEQ(uc, @"avi")) return @"video/x-msvideo";
if(STRINGEQ(uc, @"avs")) return @"video/avs-video";
if(STRINGEQ(uc, @"bcpio")) return @"application/x-bcpio";
if(STRINGEQ(uc, @"bin")) return @"application/mac-binary";
if(STRINGEQ(uc, @"bin")) return @"application/macbinary";
if(STRINGEQ(uc, @"bin")) return @"application/octet-stream";
if(STRINGEQ(uc, @"bin")) return @"application/x-binary";
if(STRINGEQ(uc, @"bin")) return @"application/x-macbinary";
if(STRINGEQ(uc, @"bm")) return @"image/bmp";
if(STRINGEQ(uc, @"bmp")) return @"image/bmp";
if(STRINGEQ(uc, @"bmp")) return @"image/x-windows-bmp";
if(STRINGEQ(uc, @"boo")) return @"application/book";
if(STRINGEQ(uc, @"book")) return @"application/book";
if(STRINGEQ(uc, @"boz")) return @"application/x-bzip2";
if(STRINGEQ(uc, @"bsh")) return @"application/x-bsh";
if(STRINGEQ(uc, @"bz")) return @"application/x-bzip";
if(STRINGEQ(uc, @"bz2")) return @"application/x-bzip2";
if(STRINGEQ(uc, @"c")) return @"text/plain";
if(STRINGEQ(uc, @"c")) return @"text/x-c";
if(STRINGEQ(uc, @"c++")) return @"text/plain";
if(STRINGEQ(uc, @"cat")) return @"application/vnd.ms-pki.seccat";
if(STRINGEQ(uc, @"cc")) return @"text/plain";
if(STRINGEQ(uc, @"cc")) return @"text/x-c";
if(STRINGEQ(uc, @"ccad")) return @"application/clariscad";
if(STRINGEQ(uc, @"cco")) return @"application/x-cocoa";
if(STRINGEQ(uc, @"cdf")) return @"application/cdf";
if(STRINGEQ(uc, @"cdf")) return @"application/x-cdf";
if(STRINGEQ(uc, @"cdf")) return @"application/x-netcdf";
if(STRINGEQ(uc, @"cer")) return @"application/pkix-cert";
if(STRINGEQ(uc, @"cer")) return @"application/x-x509-ca-cert";
if(STRINGEQ(uc, @"cha")) return @"application/x-chat";
if(STRINGEQ(uc, @"chat")) return @"application/x-chat";
if(STRINGEQ(uc, @"class")) return @"application/java";
if(STRINGEQ(uc, @"class")) return @"application/java-byte-code";
if(STRINGEQ(uc, @"class")) return @"application/x-java-class";
if(STRINGEQ(uc, @"com")) return @"application/octet-stream";
if(STRINGEQ(uc, @"com")) return @"text/plain";
if(STRINGEQ(uc, @"conf")) return @"text/plain";
if(STRINGEQ(uc, @"cpio")) return @"application/x-cpio";
if(STRINGEQ(uc, @"cpp")) return @"text/x-c";
if(STRINGEQ(uc, @"cpt")) return @"application/mac-compactpro";
if(STRINGEQ(uc, @"cpt")) return @"application/x-compactpro";
if(STRINGEQ(uc, @"cpt")) return @"application/x-cpt";
if(STRINGEQ(uc, @"crl")) return @"application/pkcs-crl";
if(STRINGEQ(uc, @"crl")) return @"application/pkix-crl";
if(STRINGEQ(uc, @"crt")) return @"application/pkix-cert";
if(STRINGEQ(uc, @"crt")) return @"application/x-x509-ca-cert";
if(STRINGEQ(uc, @"crt")) return @"application/x-x509-user-cert";
if(STRINGEQ(uc, @"csh")) return @"application/x-csh";
if(STRINGEQ(uc, @"csh")) return @"text/x-script.csh";
if(STRINGEQ(uc, @"css")) return @"application/x-pointplus";
if(STRINGEQ(uc, @"css")) return @"text/css";
if(STRINGEQ(uc, @"cxx")) return @"text/plain";
if(STRINGEQ(uc, @"dcr")) return @"application/x-director";
if(STRINGEQ(uc, @"deepv")) return @"application/x-deepv";
if(STRINGEQ(uc, @"def")) return @"text/plain";
if(STRINGEQ(uc, @"der")) return @"application/x-x509-ca-cert";
if(STRINGEQ(uc, @"dif")) return @"video/x-dv";
if(STRINGEQ(uc, @"dir")) return @"application/x-director";
if(STRINGEQ(uc, @"dl")) return @"video/dl";
if(STRINGEQ(uc, @"dl")) return @"video/x-dl";
if(STRINGEQ(uc, @"doc")) return @"application/msword";
if(STRINGEQ(uc, @"dot")) return @"application/msword";
if(STRINGEQ(uc, @"dp")) return @"application/commonground";
if(STRINGEQ(uc, @"drw")) return @"application/drafting";
if(STRINGEQ(uc, @"dump")) return @"application/octet-stream";
if(STRINGEQ(uc, @"dv")) return @"video/x-dv";
if(STRINGEQ(uc, @"dvi")) return @"application/x-dvi";
if(STRINGEQ(uc, @"dwf")) return @"drawing/x-dwf (old)";
if(STRINGEQ(uc, @"dwf")) return @"model/vnd.dwf";
if(STRINGEQ(uc, @"dwg")) return @"application/acad";
if(STRINGEQ(uc, @"dwg")) return @"image/vnd.dwg";
if(STRINGEQ(uc, @"dwg")) return @"image/x-dwg";
if(STRINGEQ(uc, @"dxf")) return @"application/dxf";
if(STRINGEQ(uc, @"dxf")) return @"image/vnd.dwg";
if(STRINGEQ(uc, @"dxf")) return @"image/x-dwg";
if(STRINGEQ(uc, @"dxr")) return @"application/x-director";
if(STRINGEQ(uc, @"el")) return @"text/x-script.elisp";
if(STRINGEQ(uc, @"elc")) return @"application/x-bytecode.elisp (compiled elisp)";
if(STRINGEQ(uc, @"elc")) return @"application/x-elc";
if(STRINGEQ(uc, @"env")) return @"application/x-envoy";
if(STRINGEQ(uc, @"eps")) return @"application/postscript";
if(STRINGEQ(uc, @"es")) return @"application/x-esrehber";
if(STRINGEQ(uc, @"etx")) return @"text/x-setext";
if(STRINGEQ(uc, @"evy")) return @"application/envoy";
if(STRINGEQ(uc, @"evy")) return @"application/x-envoy";
if(STRINGEQ(uc, @"exe")) return @"application/octet-stream";
if(STRINGEQ(uc, @"f")) return @"text/plain";
if(STRINGEQ(uc, @"f")) return @"text/x-fortran";
if(STRINGEQ(uc, @"f77")) return @"text/x-fortran";
if(STRINGEQ(uc, @"f90")) return @"text/plain";
if(STRINGEQ(uc, @"f90")) return @"text/x-fortran";
if(STRINGEQ(uc, @"fdf")) return @"application/vnd.fdf";
if(STRINGEQ(uc, @"fif")) return @"application/fractals";
if(STRINGEQ(uc, @"fif")) return @"image/fif";
if(STRINGEQ(uc, @"fli")) return @"video/fli";
if(STRINGEQ(uc, @"fli")) return @"video/x-fli";
if(STRINGEQ(uc, @"flo")) return @"image/florian";
if(STRINGEQ(uc, @"flx")) return @"text/vnd.fmi.flexstor";
if(STRINGEQ(uc, @"fmf")) return @"video/x-atomic3d-feature";
if(STRINGEQ(uc, @"for")) return @"text/plain";
if(STRINGEQ(uc, @"for")) return @"text/x-fortran";
if(STRINGEQ(uc, @"fpx")) return @"image/vnd.fpx";
if(STRINGEQ(uc, @"fpx")) return @"image/vnd.net-fpx";
if(STRINGEQ(uc, @"frl")) return @"application/freeloader";
if(STRINGEQ(uc, @"funk")) return @"audio/make";
if(STRINGEQ(uc, @"g")) return @"text/plain";
if(STRINGEQ(uc, @"g3")) return @"image/g3fax";
if(STRINGEQ(uc, @"gif")) return @"image/gif";
if(STRINGEQ(uc, @"gl")) return @"video/gl";
if(STRINGEQ(uc, @"gl")) return @"video/x-gl";
if(STRINGEQ(uc, @"gsd")) return @"audio/x-gsm";
if(STRINGEQ(uc, @"gsm")) return @"audio/x-gsm";
if(STRINGEQ(uc, @"gsp")) return @"application/x-gsp";
if(STRINGEQ(uc, @"gss")) return @"application/x-gss";
if(STRINGEQ(uc, @"gtar")) return @"application/x-gtar";
if(STRINGEQ(uc, @"gz")) return @"application/x-compressed";
if(STRINGEQ(uc, @"gz")) return @"application/x-gzip";
if(STRINGEQ(uc, @"gzip")) return @"application/x-gzip";
if(STRINGEQ(uc, @"gzip")) return @"multipart/x-gzip";
if(STRINGEQ(uc, @"h")) return @"text/plain";
if(STRINGEQ(uc, @"h")) return @"text/x-h";
if(STRINGEQ(uc, @"hdf")) return @"application/x-hdf";
if(STRINGEQ(uc, @"help")) return @"application/x-helpfile";
if(STRINGEQ(uc, @"hgl")) return @"application/vnd.hp-hpgl";
if(STRINGEQ(uc, @"hh")) return @"text/plain";
if(STRINGEQ(uc, @"hh")) return @"text/x-h";
if(STRINGEQ(uc, @"hlb")) return @"text/x-script";
if(STRINGEQ(uc, @"hlp")) return @"application/hlp";
if(STRINGEQ(uc, @"hlp")) return @"application/x-helpfile";
if(STRINGEQ(uc, @"hlp")) return @"application/x-winhelp";
if(STRINGEQ(uc, @"hpg")) return @"application/vnd.hp-hpgl";
if(STRINGEQ(uc, @"hpgl")) return @"application/vnd.hp-hpgl";
if(STRINGEQ(uc, @"hqx")) return @"application/binhex";
if(STRINGEQ(uc, @"hqx")) return @"application/binhex4";
if(STRINGEQ(uc, @"hqx")) return @"application/mac-binhex";
if(STRINGEQ(uc, @"hqx")) return @"application/mac-binhex40";
if(STRINGEQ(uc, @"hqx")) return @"application/x-binhex40";
if(STRINGEQ(uc, @"hqx")) return @"application/x-mac-binhex40";
if(STRINGEQ(uc, @"hta")) return @"application/hta";
if(STRINGEQ(uc, @"htc")) return @"text/x-component";
if(STRINGEQ(uc, @"htm")) return @"text/html";
if(STRINGEQ(uc, @"html")) return @"text/html";
if(STRINGEQ(uc, @"htmls")) return @"text/html";
if(STRINGEQ(uc, @"htt")) return @"text/webviewhtml";
if(STRINGEQ(uc, @"htx")) return @"text/html";
if(STRINGEQ(uc, @"ice")) return @"x-conference/x-cooltalk";
if(STRINGEQ(uc, @"ico")) return @"image/x-icon";
if(STRINGEQ(uc, @"idc")) return @"text/plain";
if(STRINGEQ(uc, @"ief")) return @"image/ief";
if(STRINGEQ(uc, @"iefs")) return @"image/ief";
if(STRINGEQ(uc, @"iges")) return @"application/iges";
if(STRINGEQ(uc, @"iges")) return @"model/iges";
if(STRINGEQ(uc, @"igs")) return @"application/iges";
if(STRINGEQ(uc, @"igs")) return @"model/iges";
if(STRINGEQ(uc, @"ima")) return @"application/x-ima";
if(STRINGEQ(uc, @"imap")) return @"application/x-httpd-imap";
if(STRINGEQ(uc, @"inf")) return @"application/inf";
if(STRINGEQ(uc, @"ins")) return @"application/x-internett-signup";
if(STRINGEQ(uc, @"ip")) return @"application/x-ip2";
if(STRINGEQ(uc, @"isu")) return @"video/x-isvideo";
if(STRINGEQ(uc, @"it")) return @"audio/it";
if(STRINGEQ(uc, @"iv")) return @"application/x-inventor";
if(STRINGEQ(uc, @"ivr")) return @"i-world/i-vrml";
if(STRINGEQ(uc, @"ivy")) return @"application/x-livescreen";
if(STRINGEQ(uc, @"jam")) return @"audio/x-jam";
if(STRINGEQ(uc, @"jav")) return @"text/plain";
if(STRINGEQ(uc, @"jav")) return @"text/x-java-source";
if(STRINGEQ(uc, @"java")) return @"text/plain";
if(STRINGEQ(uc, @"java")) return @"text/x-java-source";
if(STRINGEQ(uc, @"jcm")) return @"application/x-java-commerce";
if(STRINGEQ(uc, @"jfif")) return @"image/jpeg";
if(STRINGEQ(uc, @"jfif")) return @"image/pjpeg";
if(STRINGEQ(uc, @"jfif-tbnl")) return @"image/jpeg";
if(STRINGEQ(uc, @"jpe")) return @"image/jpeg";
if(STRINGEQ(uc, @"jpe")) return @"image/pjpeg";
if(STRINGEQ(uc, @"jpeg")) return @"image/jpeg";
if(STRINGEQ(uc, @"jpeg")) return @"image/pjpeg";
if(STRINGEQ(uc, @"jpg")) return @"image/jpeg";
if(STRINGEQ(uc, @"thm")) return @"image/jpeg";
if(STRINGEQ(uc, @"jpg")) return @"image/pjpeg";
if(STRINGEQ(uc, @"jps")) return @"image/x-jps";
if(STRINGEQ(uc, @"js")) return @"application/x-javascript";
if(STRINGEQ(uc, @"jut")) return @"image/jutvision";
if(STRINGEQ(uc, @"kar")) return @"audio/midi";
if(STRINGEQ(uc, @"kar")) return @"music/x-karaoke";
if(STRINGEQ(uc, @"ksh")) return @"application/x-ksh";
if(STRINGEQ(uc, @"ksh")) return @"text/x-script.ksh";
if(STRINGEQ(uc, @"la")) return @"audio/nspaudio";
if(STRINGEQ(uc, @"la")) return @"audio/x-nspaudio";
if(STRINGEQ(uc, @"lam")) return @"audio/x-liveaudio";
if(STRINGEQ(uc, @"latex")) return @"application/x-latex";
if(STRINGEQ(uc, @"lha")) return @"application/lha";
if(STRINGEQ(uc, @"lha")) return @"application/octet-stream";
if(STRINGEQ(uc, @"lha")) return @"application/x-lha";
if(STRINGEQ(uc, @"lhx")) return @"application/octet-stream";
if(STRINGEQ(uc, @"list")) return @"text/plain";
if(STRINGEQ(uc, @"lma")) return @"audio/nspaudio";
if(STRINGEQ(uc, @"lma")) return @"audio/x-nspaudio";
if(STRINGEQ(uc, @"log")) return @"text/plain";
if(STRINGEQ(uc, @"lsp")) return @"application/x-lisp";
if(STRINGEQ(uc, @"lsp")) return @"text/x-script.lisp";
if(STRINGEQ(uc, @"lst")) return @"text/plain";
if(STRINGEQ(uc, @"lsx")) return @"text/x-la-asf";
if(STRINGEQ(uc, @"ltx")) return @"application/x-latex";
if(STRINGEQ(uc, @"lzh")) return @"application/octet-stream";
if(STRINGEQ(uc, @"lzh")) return @"application/x-lzh";
if(STRINGEQ(uc, @"lzx")) return @"application/lzx";
if(STRINGEQ(uc, @"lzx")) return @"application/octet-stream";
if(STRINGEQ(uc, @"lzx")) return @"application/x-lzx";
if(STRINGEQ(uc, @"m")) return @"text/plain";
if(STRINGEQ(uc, @"m")) return @"text/x-m";
if(STRINGEQ(uc, @"m1v")) return @"video/mpeg";
if(STRINGEQ(uc, @"m2a")) return @"audio/mpeg";
if(STRINGEQ(uc, @"m2v")) return @"video/mpeg";
if(STRINGEQ(uc, @"m3u")) return @"audio/x-mpequrl";
if(STRINGEQ(uc, @"man")) return @"application/x-troff-man";
if(STRINGEQ(uc, @"map")) return @"application/x-navimap";
if(STRINGEQ(uc, @"mar")) return @"text/plain";
if(STRINGEQ(uc, @"mbd")) return @"application/mbedlet";
if(STRINGEQ(uc, @"mc$")) return @"application/x-magic-cap-package-1.0";
if(STRINGEQ(uc, @"mcd")) return @"application/mcad";
if(STRINGEQ(uc, @"mcd")) return @"application/x-mathcad";
if(STRINGEQ(uc, @"mcf")) return @"image/vasa";
if(STRINGEQ(uc, @"mcf")) return @"text/mcf";
if(STRINGEQ(uc, @"mcp")) return @"application/netmc";
if(STRINGEQ(uc, @"me")) return @"application/x-troff-me";
if(STRINGEQ(uc, @"mht")) return @"message/rfc822";
if(STRINGEQ(uc, @"mhtml")) return @"message/rfc822";
if(STRINGEQ(uc, @"mid")) return @"application/x-midi";
if(STRINGEQ(uc, @"mid")) return @"audio/midi";
if(STRINGEQ(uc, @"mid")) return @"audio/x-mid";
if(STRINGEQ(uc, @"mid")) return @"audio/x-midi";
if(STRINGEQ(uc, @"mid")) return @"music/crescendo";
if(STRINGEQ(uc, @"mid")) return @"x-music/x-midi";
if(STRINGEQ(uc, @"midi")) return @"application/x-midi";
if(STRINGEQ(uc, @"midi")) return @"audio/midi";
if(STRINGEQ(uc, @"midi")) return @"audio/x-mid";
if(STRINGEQ(uc, @"midi")) return @"audio/x-midi";
if(STRINGEQ(uc, @"midi")) return @"music/crescendo";
if(STRINGEQ(uc, @"midi")) return @"x-music/x-midi";
if(STRINGEQ(uc, @"mif")) return @"application/x-frame";
if(STRINGEQ(uc, @"mif")) return @"application/x-mif";
if(STRINGEQ(uc, @"mime")) return @"message/rfc822";
if(STRINGEQ(uc, @"mime")) return @"www/mime";
if(STRINGEQ(uc, @"mjf")) return @"audio/x-vnd.audioexplosion.mjuicemediafile";
if(STRINGEQ(uc, @"mjpg")) return @"video/x-motion-jpeg";
if(STRINGEQ(uc, @"mm")) return @"application/base64";
if(STRINGEQ(uc, @"mm")) return @"application/x-meme";
if(STRINGEQ(uc, @"mme")) return @"application/base64";
if(STRINGEQ(uc, @"mod")) return @"audio/mod";
if(STRINGEQ(uc, @"mod")) return @"audio/x-mod";
if(STRINGEQ(uc, @"moov")) return @"video/quicktime";
if(STRINGEQ(uc, @"mov")) return @"video/quicktime";
if(STRINGEQ(uc, @"movie")) return @"video/x-sgi-movie";
if(STRINGEQ(uc, @"mp2")) return @"audio/mpeg";
if(STRINGEQ(uc, @"mp2")) return @"audio/x-mpeg";
if(STRINGEQ(uc, @"mp2")) return @"video/mpeg";
if(STRINGEQ(uc, @"mp2")) return @"video/x-mpeg";
if(STRINGEQ(uc, @"mp2")) return @"video/x-mpeq2a";
if(STRINGEQ(uc, @"mp3")) return @"audio/mpeg3";
if(STRINGEQ(uc, @"mp3")) return @"audio/x-mpeg-3";
if(STRINGEQ(uc, @"mp3")) return @"video/mpeg";
if(STRINGEQ(uc, @"mp3")) return @"video/x-mpeg";
if(STRINGEQ(uc, @"mpa")) return @"audio/mpeg";
if(STRINGEQ(uc, @"mpa")) return @"video/mpeg";
if(STRINGEQ(uc, @"mpc")) return @"application/x-project";
if(STRINGEQ(uc, @"mpe")) return @"video/mpeg";
if(STRINGEQ(uc, @"mpeg")) return @"video/mpeg";
if(STRINGEQ(uc, @"mpg")) return @"audio/mpeg";
if(STRINGEQ(uc, @"mpg")) return @"video/mpeg";
if(STRINGEQ(uc, @"mpga")) return @"audio/mpeg";
if(STRINGEQ(uc, @"mpp")) return @"application/vnd.ms-project";
if(STRINGEQ(uc, @"mpt")) return @"application/x-project";
if(STRINGEQ(uc, @"mpv")) return @"application/x-project";
if(STRINGEQ(uc, @"mpx")) return @"application/x-project";
if(STRINGEQ(uc, @"mrc")) return @"application/marc";
if(STRINGEQ(uc, @"ms")) return @"application/x-troff-ms";
if(STRINGEQ(uc, @"mv")) return @"video/x-sgi-movie";
if(STRINGEQ(uc, @"my")) return @"audio/make";
if(STRINGEQ(uc, @"mzz")) return @"application/x-vnd.audioexplosion.mzz";
if(STRINGEQ(uc, @"nap")) return @"image/naplps";
if(STRINGEQ(uc, @"naplps")) return @"image/naplps";
if(STRINGEQ(uc, @"nc")) return @"application/x-netcdf";
if(STRINGEQ(uc, @"ncm")) return @"application/vnd.nokia.configuration-message";
if(STRINGEQ(uc, @"nif")) return @"image/x-niff";
if(STRINGEQ(uc, @"niff")) return @"image/x-niff";
if(STRINGEQ(uc, @"nix")) return @"application/x-mix-transfer";
if(STRINGEQ(uc, @"nsc")) return @"application/x-conference";
if(STRINGEQ(uc, @"nvd")) return @"application/x-navidoc";
if(STRINGEQ(uc, @"o")) return @"application/octet-stream";
if(STRINGEQ(uc, @"oda")) return @"application/oda";
if(STRINGEQ(uc, @"omc")) return @"application/x-omc";
if(STRINGEQ(uc, @"omcd")) return @"application/x-omcdatamaker";
if(STRINGEQ(uc, @"omcr")) return @"application/x-omcregerator";
if(STRINGEQ(uc, @"p")) return @"text/x-pascal";
if(STRINGEQ(uc, @"p10")) return @"application/pkcs10";
if(STRINGEQ(uc, @"p10")) return @"application/x-pkcs10";
if(STRINGEQ(uc, @"p12")) return @"application/pkcs-12";
if(STRINGEQ(uc, @"p12")) return @"application/x-pkcs12";
if(STRINGEQ(uc, @"p7a")) return @"application/x-pkcs7-signature";
if(STRINGEQ(uc, @"p7c")) return @"application/pkcs7-mime";
if(STRINGEQ(uc, @"p7c")) return @"application/x-pkcs7-mime";
if(STRINGEQ(uc, @"p7m")) return @"application/pkcs7-mime";
if(STRINGEQ(uc, @"p7m")) return @"application/x-pkcs7-mime";
if(STRINGEQ(uc, @"p7r")) return @"application/x-pkcs7-certreqresp";
if(STRINGEQ(uc, @"p7s")) return @"application/pkcs7-signature";
if(STRINGEQ(uc, @"part")) return @"application/pro_eng";
if(STRINGEQ(uc, @"pas")) return @"text/pascal";
if(STRINGEQ(uc, @"pbm")) return @"image/x-portable-bitmap";
if(STRINGEQ(uc, @"pcl")) return @"application/vnd.hp-pcl";
if(STRINGEQ(uc, @"pcl")) return @"application/x-pcl";
if(STRINGEQ(uc, @"pct")) return @"image/x-pict";
if(STRINGEQ(uc, @"pcx")) return @"image/x-pcx";
if(STRINGEQ(uc, @"pdb")) return @"chemical/x-pdb";
if(STRINGEQ(uc, @"pdf")) return @"application/pdf";
if(STRINGEQ(uc, @"pfunk")) return @"audio/make";
if(STRINGEQ(uc, @"pfunk")) return @"audio/make.my.funk";
if(STRINGEQ(uc, @"pgm")) return @"image/x-portable-graymap";
if(STRINGEQ(uc, @"pgm")) return @"image/x-portable-greymap";
if(STRINGEQ(uc, @"pic")) return @"image/pict";
if(STRINGEQ(uc, @"pict")) return @"image/pict";
if(STRINGEQ(uc, @"pkg")) return @"application/x-newton-compatible-pkg";
if(STRINGEQ(uc, @"pko")) return @"application/vnd.ms-pki.pko";
if(STRINGEQ(uc, @"pl")) return @"text/plain";
if(STRINGEQ(uc, @"pl")) return @"text/x-script.perl";
if(STRINGEQ(uc, @"plist")) return @"text/plain";
if(STRINGEQ(uc, @"plx")) return @"application/x-pixclscript";
if(STRINGEQ(uc, @"pm")) return @"image/x-xpixmap";
if(STRINGEQ(uc, @"pm")) return @"text/x-script.perl-module";
if(STRINGEQ(uc, @"pm4")) return @"application/x-pagemaker";
if(STRINGEQ(uc, @"pm5")) return @"application/x-pagemaker";
if(STRINGEQ(uc, @"png")) return @"image/png";
if(STRINGEQ(uc, @"pnm")) return @"application/x-portable-anymap";
if(STRINGEQ(uc, @"pnm")) return @"image/x-portable-anymap";
if(STRINGEQ(uc, @"pot")) return @"application/mspowerpoint";
if(STRINGEQ(uc, @"pot")) return @"application/vnd.ms-powerpoint";
if(STRINGEQ(uc, @"pov")) return @"model/x-pov";
if(STRINGEQ(uc, @"ppa")) return @"application/vnd.ms-powerpoint";
if(STRINGEQ(uc, @"ppm")) return @"image/x-portable-pixmap";
if(STRINGEQ(uc, @"pps")) return @"application/mspowerpoint";
if(STRINGEQ(uc, @"pps")) return @"application/vnd.ms-powerpoint";
if(STRINGEQ(uc, @"ppt")) return @"application/mspowerpoint";
if(STRINGEQ(uc, @"ppt")) return @"application/powerpoint";
if(STRINGEQ(uc, @"ppt")) return @"application/vnd.ms-powerpoint";
if(STRINGEQ(uc, @"ppt")) return @"application/x-mspowerpoint";
if(STRINGEQ(uc, @"ppz")) return @"application/mspowerpoint";
if(STRINGEQ(uc, @"pre")) return @"application/x-freelance";
if(STRINGEQ(uc, @"prt")) return @"application/pro_eng";
if(STRINGEQ(uc, @"ps")) return @"application/postscript";
if(STRINGEQ(uc, @"psd")) return @"application/octet-stream";
if(STRINGEQ(uc, @"pvu")) return @"paleovu/x-pv";
if(STRINGEQ(uc, @"pwz")) return @"application/vnd.ms-powerpoint";
if(STRINGEQ(uc, @"py")) return @"text/x-script.phyton";
if(STRINGEQ(uc, @"pyc")) return @"applicaiton/x-bytecode.python";
if(STRINGEQ(uc, @"qcp")) return @"audio/vnd.qcelp";
if(STRINGEQ(uc, @"qd3")) return @"x-world/x-3dmf";
if(STRINGEQ(uc, @"qd3d")) return @"x-world/x-3dmf";
if(STRINGEQ(uc, @"qif")) return @"image/x-quicktime";
if(STRINGEQ(uc, @"qt")) return @"video/quicktime";
if(STRINGEQ(uc, @"qtc")) return @"video/x-qtc";
if(STRINGEQ(uc, @"qti")) return @"image/x-quicktime";
if(STRINGEQ(uc, @"qtif")) return @"image/x-quicktime";
if(STRINGEQ(uc, @"ra")) return @"audio/x-pn-realaudio";
if(STRINGEQ(uc, @"ra")) return @"audio/x-pn-realaudio-plugin";
if(STRINGEQ(uc, @"ra")) return @"audio/x-realaudio";
if(STRINGEQ(uc, @"ram")) return @"audio/x-pn-realaudio";
if(STRINGEQ(uc, @"ras")) return @"application/x-cmu-raster";
if(STRINGEQ(uc, @"ras")) return @"image/cmu-raster";
if(STRINGEQ(uc, @"ras")) return @"image/x-cmu-raster";
if(STRINGEQ(uc, @"rast")) return @"image/cmu-raster";
if(STRINGEQ(uc, @"rexx")) return @"text/x-script.rexx";
if(STRINGEQ(uc, @"rf")) return @"image/vnd.rn-realflash";
if(STRINGEQ(uc, @"rgb")) return @"image/x-rgb";
if(STRINGEQ(uc, @"rm")) return @"application/vnd.rn-realmedia";
if(STRINGEQ(uc, @"rm")) return @"audio/x-pn-realaudio";
if(STRINGEQ(uc, @"rmi")) return @"audio/mid";
if(STRINGEQ(uc, @"rmm")) return @"audio/x-pn-realaudio";
if(STRINGEQ(uc, @"rmp")) return @"audio/x-pn-realaudio";
if(STRINGEQ(uc, @"rmp")) return @"audio/x-pn-realaudio-plugin";
if(STRINGEQ(uc, @"rng")) return @"application/ringing-tones";
if(STRINGEQ(uc, @"rng")) return @"application/vnd.nokia.ringing-tone";
if(STRINGEQ(uc, @"rnx")) return @"application/vnd.rn-realplayer";
if(STRINGEQ(uc, @"roff")) return @"application/x-troff";
if(STRINGEQ(uc, @"rp")) return @"image/vnd.rn-realpix";
if(STRINGEQ(uc, @"rpm")) return @"audio/x-pn-realaudio-plugin";
if(STRINGEQ(uc, @"rt")) return @"text/richtext";
if(STRINGEQ(uc, @"rt")) return @"text/vnd.rn-realtext";
if(STRINGEQ(uc, @"rtf")) return @"application/rtf";
if(STRINGEQ(uc, @"rtf")) return @"application/x-rtf";
if(STRINGEQ(uc, @"rtf")) return @"text/richtext";
if(STRINGEQ(uc, @"rtx")) return @"application/rtf";
if(STRINGEQ(uc, @"rtx")) return @"text/richtext";
if(STRINGEQ(uc, @"rv")) return @"video/vnd.rn-realvideo";
if(STRINGEQ(uc, @"s")) return @"text/x-asm";
if(STRINGEQ(uc, @"s3m")) return @"audio/s3m";
if(STRINGEQ(uc, @"saveme")) return @"application/octet-stream";
if(STRINGEQ(uc, @"sbk")) return @"application/x-tbook";
if(STRINGEQ(uc, @"scm")) return @"application/x-lotusscreencam";
if(STRINGEQ(uc, @"scm")) return @"text/x-script.guile";
if(STRINGEQ(uc, @"scm")) return @"text/x-script.scheme";
if(STRINGEQ(uc, @"scm")) return @"video/x-scm";
if(STRINGEQ(uc, @"sdml")) return @"text/plain";
if(STRINGEQ(uc, @"sdp")) return @"application/sdp";
if(STRINGEQ(uc, @"sdp")) return @"application/x-sdp";
if(STRINGEQ(uc, @"sdr")) return @"application/sounder";
if(STRINGEQ(uc, @"sea")) return @"application/sea";
if(STRINGEQ(uc, @"sea")) return @"application/x-sea";
if(STRINGEQ(uc, @"set")) return @"application/set";
if(STRINGEQ(uc, @"sgm")) return @"text/sgml";
if(STRINGEQ(uc, @"sgm")) return @"text/x-sgml";
if(STRINGEQ(uc, @"sgml")) return @"text/sgml";
if(STRINGEQ(uc, @"sgml")) return @"text/x-sgml";
if(STRINGEQ(uc, @"sh")) return @"application/x-bsh";
if(STRINGEQ(uc, @"sh")) return @"application/x-sh";
if(STRINGEQ(uc, @"sh")) return @"application/x-shar";
if(STRINGEQ(uc, @"sh")) return @"text/x-script.sh";
if(STRINGEQ(uc, @"shar")) return @"application/x-bsh";
if(STRINGEQ(uc, @"shar")) return @"application/x-shar";
if(STRINGEQ(uc, @"shtml")) return @"text/html";
if(STRINGEQ(uc, @"shtml")) return @"text/x-server-parsed-html";
if(STRINGEQ(uc, @"sid")) return @"audio/x-psid";
if(STRINGEQ(uc, @"sit")) return @"application/x-sit";
if(STRINGEQ(uc, @"sit")) return @"application/x-stuffit";
if(STRINGEQ(uc, @"skd")) return @"application/x-koan";
if(STRINGEQ(uc, @"skm")) return @"application/x-koan";
if(STRINGEQ(uc, @"skp")) return @"application/x-koan";
if(STRINGEQ(uc, @"skt")) return @"application/x-koan";
if(STRINGEQ(uc, @"sl")) return @"application/x-seelogo";
if(STRINGEQ(uc, @"smi")) return @"application/smil";
if(STRINGEQ(uc, @"smil")) return @"application/smil";
if(STRINGEQ(uc, @"snd")) return @"audio/basic";
if(STRINGEQ(uc, @"snd")) return @"audio/x-adpcm";
if(STRINGEQ(uc, @"sol")) return @"application/solids";
if(STRINGEQ(uc, @"spc")) return @"application/x-pkcs7-certificates";
if(STRINGEQ(uc, @"spc")) return @"text/x-speech";
if(STRINGEQ(uc, @"spl")) return @"application/futuresplash";
if(STRINGEQ(uc, @"spr")) return @"application/x-sprite";
if(STRINGEQ(uc, @"sprite")) return @"application/x-sprite";
if(STRINGEQ(uc, @"src")) return @"application/x-wais-source";
if(STRINGEQ(uc, @"ssi")) return @"text/x-server-parsed-html";
if(STRINGEQ(uc, @"ssm")) return @"application/streamingmedia";
if(STRINGEQ(uc, @"sst")) return @"application/vnd.ms-pki.certstore";
if(STRINGEQ(uc, @"step")) return @"application/step";
if(STRINGEQ(uc, @"stl")) return @"application/sla";
if(STRINGEQ(uc, @"stl")) return @"application/vnd.ms-pki.stl";
if(STRINGEQ(uc, @"stl")) return @"application/x-navistyle";
if(STRINGEQ(uc, @"stp")) return @"application/step";
if(STRINGEQ(uc, @"sv4cpio")) return @"application/x-sv4cpio";
if(STRINGEQ(uc, @"sv4crc")) return @"application/x-sv4crc";
if(STRINGEQ(uc, @"svf")) return @"image/vnd.dwg";
if(STRINGEQ(uc, @"svf")) return @"image/x-dwg";
if(STRINGEQ(uc, @"svr")) return @"application/x-world";
if(STRINGEQ(uc, @"svr")) return @"x-world/x-svr";
if(STRINGEQ(uc, @"swf")) return @"application/x-shockwave-flash";
if(STRINGEQ(uc, @"t")) return @"application/x-troff";
if(STRINGEQ(uc, @"talk")) return @"text/x-speech";
if(STRINGEQ(uc, @"tar")) return @"application/x-tar";
if(STRINGEQ(uc, @"tbk")) return @"application/toolbook";
if(STRINGEQ(uc, @"tbk")) return @"application/x-tbook";
if(STRINGEQ(uc, @"tcl")) return @"application/x-tcl";
if(STRINGEQ(uc, @"tcl")) return @"text/x-script.tcl";
if(STRINGEQ(uc, @"tcsh")) return @"text/x-script.tcsh";
if(STRINGEQ(uc, @"tex")) return @"application/x-tex";
if(STRINGEQ(uc, @"texi")) return @"application/x-texinfo";
if(STRINGEQ(uc, @"texinfo")) return @"application/x-texinfo";
if(STRINGEQ(uc, @"text")) return @"application/plain";
if(STRINGEQ(uc, @"text")) return @"text/plain";
if(STRINGEQ(uc, @"tgz")) return @"application/gnutar";
if(STRINGEQ(uc, @"tgz")) return @"application/x-compressed";
if(STRINGEQ(uc, @"tif")) return @"image/tiff";
if(STRINGEQ(uc, @"tif")) return @"image/x-tiff";
if(STRINGEQ(uc, @"tiff")) return @"image/tiff";
if(STRINGEQ(uc, @"tiff")) return @"image/x-tiff";
if(STRINGEQ(uc, @"tr")) return @"application/x-troff";
if(STRINGEQ(uc, @"tsi")) return @"audio/tsp-audio";
if(STRINGEQ(uc, @"tsp")) return @"application/dsptype";
if(STRINGEQ(uc, @"tsp")) return @"audio/tsplayer";
if(STRINGEQ(uc, @"tsv")) return @"text/tab-separated-values";
if(STRINGEQ(uc, @"turbot")) return @"image/florian";
if(STRINGEQ(uc, @"txt")) return @"text/plain";
if(STRINGEQ(uc, @"uil")) return @"text/x-uil";
if(STRINGEQ(uc, @"uni")) return @"text/uri-list";
if(STRINGEQ(uc, @"unis")) return @"text/uri-list";
if(STRINGEQ(uc, @"unv")) return @"application/i-deas";
if(STRINGEQ(uc, @"uri")) return @"text/uri-list";
if(STRINGEQ(uc, @"uris")) return @"text/uri-list";
if(STRINGEQ(uc, @"ustar")) return @"application/x-ustar";
if(STRINGEQ(uc, @"ustar")) return @"multipart/x-ustar";
if(STRINGEQ(uc, @"uu")) return @"application/octet-stream";
if(STRINGEQ(uc, @"uu")) return @"text/x-uuencode";
if(STRINGEQ(uc, @"uue")) return @"text/x-uuencode";
if(STRINGEQ(uc, @"vcd")) return @"application/x-cdlink";
if(STRINGEQ(uc, @"vcs")) return @"text/x-vcalendar";
if(STRINGEQ(uc, @"vda")) return @"application/vda";
if(STRINGEQ(uc, @"vdo")) return @"video/vdo";
if(STRINGEQ(uc, @"vew")) return @"application/groupwise";
if(STRINGEQ(uc, @"viv")) return @"video/vivo";
if(STRINGEQ(uc, @"viv")) return @"video/vnd.vivo";
if(STRINGEQ(uc, @"vivo")) return @"video/vivo";
if(STRINGEQ(uc, @"vivo")) return @"video/vnd.vivo";
if(STRINGEQ(uc, @"vmd")) return @"application/vocaltec-media-desc";
if(STRINGEQ(uc, @"vmf")) return @"application/vocaltec-media-file";
if(STRINGEQ(uc, @"voc")) return @"audio/voc";
if(STRINGEQ(uc, @"voc")) return @"audio/x-voc";
if(STRINGEQ(uc, @"vos")) return @"video/vosaic";
if(STRINGEQ(uc, @"vox")) return @"audio/voxware";
if(STRINGEQ(uc, @"vqe")) return @"audio/x-twinvq-plugin";
if(STRINGEQ(uc, @"vqf")) return @"audio/x-twinvq";
if(STRINGEQ(uc, @"vql")) return @"audio/x-twinvq-plugin";
if(STRINGEQ(uc, @"vrml")) return @"application/x-vrml";
if(STRINGEQ(uc, @"vrml")) return @"model/vrml";
if(STRINGEQ(uc, @"vrml")) return @"x-world/x-vrml";
if(STRINGEQ(uc, @"vrt")) return @"x-world/x-vrt";
if(STRINGEQ(uc, @"vsd")) return @"application/x-visio";
if(STRINGEQ(uc, @"vst")) return @"application/x-visio";
if(STRINGEQ(uc, @"vsw")) return @"application/x-visio";
if(STRINGEQ(uc, @"w60")) return @"application/wordperfect6.0";
if(STRINGEQ(uc, @"w61")) return @"application/wordperfect6.1";
if(STRINGEQ(uc, @"w6w")) return @"application/msword";
if(STRINGEQ(uc, @"wav")) return @"audio/wav";
if(STRINGEQ(uc, @"wav")) return @"audio/x-wav";
if(STRINGEQ(uc, @"wb1")) return @"application/x-qpro";
if(STRINGEQ(uc, @"wbmp")) return @"image/vnd.wap.wbmp";
if(STRINGEQ(uc, @"web")) return @"application/vnd.xara";
if(STRINGEQ(uc, @"wiz")) return @"application/msword";
if(STRINGEQ(uc, @"wk1")) return @"application/x-123";
if(STRINGEQ(uc, @"wmf")) return @"windows/metafile";
if(STRINGEQ(uc, @"wml")) return @"text/vnd.wap.wml";
if(STRINGEQ(uc, @"wmlc")) return @"application/vnd.wap.wmlc";
if(STRINGEQ(uc, @"wmls")) return @"text/vnd.wap.wmlscript";
if(STRINGEQ(uc, @"wmlsc")) return @"application/vnd.wap.wmlscriptc";
if(STRINGEQ(uc, @"word")) return @"application/msword";
if(STRINGEQ(uc, @"wp")) return @"application/wordperfect";
if(STRINGEQ(uc, @"wp5")) return @"application/wordperfect";
if(STRINGEQ(uc, @"wp5")) return @"application/wordperfect6.0";
if(STRINGEQ(uc, @"wp6")) return @"application/wordperfect";
if(STRINGEQ(uc, @"wpd")) return @"application/wordperfect";
if(STRINGEQ(uc, @"wpd")) return @"application/x-wpwin";
if(STRINGEQ(uc, @"wq1")) return @"application/x-lotus";
if(STRINGEQ(uc, @"wri")) return @"application/mswrite";
if(STRINGEQ(uc, @"wri")) return @"application/x-wri";
if(STRINGEQ(uc, @"wrl")) return @"application/x-world";
if(STRINGEQ(uc, @"wrl")) return @"model/vrml";
if(STRINGEQ(uc, @"wrl")) return @"x-world/x-vrml";
if(STRINGEQ(uc, @"wrz")) return @"model/vrml";
if(STRINGEQ(uc, @"wrz")) return @"x-world/x-vrml";
if(STRINGEQ(uc, @"wsc")) return @"text/scriplet";
if(STRINGEQ(uc, @"wsrc")) return @"application/x-wais-source";
if(STRINGEQ(uc, @"wtk")) return @"application/x-wintalk";
if(STRINGEQ(uc, @"xbm")) return @"image/x-xbitmap";
if(STRINGEQ(uc, @"xbm")) return @"image/x-xbm";
if(STRINGEQ(uc, @"xbm")) return @"image/xbm";
if(STRINGEQ(uc, @"xdr")) return @"video/x-amt-demorun";
if(STRINGEQ(uc, @"xgz")) return @"xgl/drawing";
if(STRINGEQ(uc, @"xif")) return @"image/vnd.xiff";
if(STRINGEQ(uc, @"xl")) return @"application/excel";
if(STRINGEQ(uc, @"xla")) return @"application/excel";
if(STRINGEQ(uc, @"xla")) return @"application/x-excel";
if(STRINGEQ(uc, @"xla")) return @"application/x-msexcel";
if(STRINGEQ(uc, @"xlb")) return @"application/excel";
if(STRINGEQ(uc, @"xlb")) return @"application/vnd.ms-excel";
if(STRINGEQ(uc, @"xlb")) return @"application/x-excel";
if(STRINGEQ(uc, @"xlc")) return @"application/excel";
if(STRINGEQ(uc, @"xlc")) return @"application/vnd.ms-excel";
if(STRINGEQ(uc, @"xlc")) return @"application/x-excel";
if(STRINGEQ(uc, @"xld")) return @"application/excel";
if(STRINGEQ(uc, @"xld")) return @"application/x-excel";
if(STRINGEQ(uc, @"xlk")) return @"application/excel";
if(STRINGEQ(uc, @"xlk")) return @"application/x-excel";
if(STRINGEQ(uc, @"xll")) return @"application/excel";
if(STRINGEQ(uc, @"xll")) return @"application/vnd.ms-excel";
if(STRINGEQ(uc, @"xll")) return @"application/x-excel";
if(STRINGEQ(uc, @"xlm")) return @"application/excel";
if(STRINGEQ(uc, @"xlm")) return @"application/vnd.ms-excel";
if(STRINGEQ(uc, @"xlm")) return @"application/x-excel";
if(STRINGEQ(uc, @"xls")) return @"application/excel";
if(STRINGEQ(uc, @"xls")) return @"application/vnd.ms-excel";
if(STRINGEQ(uc, @"xls")) return @"application/x-excel";
if(STRINGEQ(uc, @"xls")) return @"application/x-msexcel";
if(STRINGEQ(uc, @"xlt")) return @"application/excel";
if(STRINGEQ(uc, @"xlt")) return @"application/x-excel";
if(STRINGEQ(uc, @"xlv")) return @"application/excel";
if(STRINGEQ(uc, @"xlv")) return @"application/x-excel";
if(STRINGEQ(uc, @"xlw")) return @"application/excel";
if(STRINGEQ(uc, @"xlw")) return @"application/vnd.ms-excel";
if(STRINGEQ(uc, @"xlw")) return @"application/x-excel";
if(STRINGEQ(uc, @"xlw")) return @"application/x-msexcel";
if(STRINGEQ(uc, @"xm")) return @"audio/xm";
if(STRINGEQ(uc, @"xml")) return @"application/xml";
if(STRINGEQ(uc, @"xml")) return @"text/xml";
if(STRINGEQ(uc, @"xmz")) return @"xgl/movie";
if(STRINGEQ(uc, @"xpix")) return @"application/x-vnd.ls-xpix";
if(STRINGEQ(uc, @"xpm")) return @"image/x-xpixmap";
if(STRINGEQ(uc, @"xpm")) return @"image/xpm";
if(STRINGEQ(uc, @"x-png")) return @"image/png";
if(STRINGEQ(uc, @"xsr")) return @"video/x-amt-showrun";
if(STRINGEQ(uc, @"xwd")) return @"image/x-xwd";
if(STRINGEQ(uc, @"xwd")) return @"image/x-xwindowdump";
if(STRINGEQ(uc, @"xyz")) return @"chemical/x-pdb";
if(STRINGEQ(uc, @"z")) return @"application/x-compress";
if(STRINGEQ(uc, @"z")) return @"application/x-compressed";
if(STRINGEQ(uc, @"zip")) return @"application/x-compressed";
if(STRINGEQ(uc, @"zip")) return @"application/x-zip-compressed";
if(STRINGEQ(uc, @"zip")) return @"application/zip";
if(STRINGEQ(uc, @"zip")) return @"multipart/x-zip";
if(STRINGEQ(uc, @"zoo")) return @"application/octet-stream";
if(STRINGEQ(uc, @"zsh")) return @"text/x-script.zsh";
return @"unknown/unknown";
}

View File

@@ -0,0 +1,9 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#import <UIKit/UIKit.h>
NSString *mimeForExtension(NSString *extension);

View File

@@ -0,0 +1,49 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#import "MIMEHelper.h"
#define STRINGEQ(X,Y) ([X caseInsensitiveCompare:Y] == NSOrderedSame)
static NSDictionary *mimeTypes;
void initializeMimeTypeDictionary()
{
NSError *error;
NSString *mimefile = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ApacheMIMETypes" ofType:@"txt"] encoding:NSUTF8StringEncoding error:&error];
if (!mimefile)
{
NSLog(@"Could not read in mime type file: %@", error.localizedFailureReason);
return;
}
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
NSArray *lines = [mimefile componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
for (NSString *eachLine in lines)
{
NSString *line = [eachLine stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if (line.length < 2) continue;
if ([line hasPrefix:@"#"]) continue;
NSArray *items = [line componentsSeparatedByString:@"\t"];
if (items.count < 2) continue;
NSString *mimeType = [items objectAtIndex:0];
NSArray *extensions = [[items lastObject] componentsSeparatedByString:@" "];
for (NSString *extension in extensions)
dict[extension] = mimeType;
}
mimeTypes = dict;
}
NSString *mimeForExtension(NSString *extension)
{
if (!mimeTypes)
initializeMimeTypeDictionary();
return mimeTypes[[extension lowercaseString]];
}

View File

@@ -0,0 +1,29 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 5.x Edition
BSD License, Use at your own risk
*/
#import <Foundation/Foundation.h>
#import <MobileCoreServices/MobileCoreServices.h>
NSString *uuid();
NSString *preferredExtensionForUTI(NSString *aUTI);
NSString *preferredMimeTypeForUTI(NSString *aUTI);
NSString *preferredUTIForExtension(NSString *ext);
NSString *preferredUTIForMIMEType(NSString *mime);
NSArray *allExtensions(NSString *aUTI);
NSArray *allMIMETypes(NSString *aUTI);
NSDictionary *utiDictionary(NSString *aUTI);
NSArray *conformanceArray(NSString *aUTI);
NSArray *allUTIsForExtension(NSString *ext);
BOOL pathPointsToLikelyUTIMatch(NSString *path, CFStringRef theUTI);
// You can add any number of these as desired.
BOOL pathPointsToLikelyImage(NSString *path);
BOOL pathPointsToLikelyAudio(NSString *path);

View File

@@ -0,0 +1,153 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 5.x Edition
BSD License, Use at your own risk
*/
#import "UTIHelper.h"
NSString *uuid()
{
CFUUIDRef theUUID = CFUUIDCreate(NULL);
NSString *uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return uuidString;
}
NSString *preferredExtensionForUTI(NSString *aUTI)
{
CFStringRef theUTI = (__bridge CFStringRef) aUTI;
CFStringRef results = UTTypeCopyPreferredTagWithClass(theUTI, kUTTagClassFilenameExtension);
return (__bridge_transfer NSString *)results;
}
NSString *preferredMimeTypeForUTI(NSString *aUTI)
{
CFStringRef theUTI = (__bridge CFStringRef) aUTI;
CFStringRef results = UTTypeCopyPreferredTagWithClass(theUTI, kUTTagClassMIMEType);
return (__bridge_transfer NSString *)results;
}
NSString *preferredUTIForExtension(NSString *ext)
{
// Request the UTI via the file extension
NSString *theUTI = (__bridge_transfer NSString *) UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef) ext, NULL);
return theUTI;
}
NSString *preferredUTIForMIMEType(NSString *mime)
{
// Request the UTI via the file extension
NSString *theUTI = (__bridge_transfer NSString *) UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, (__bridge CFStringRef) mime, NULL);
return theUTI;
}
NSDictionary *utiDictionary(NSString *aUTI)
{
NSDictionary *dictionary = (__bridge_transfer NSDictionary *)UTTypeCopyDeclaration((__bridge CFStringRef) aUTI);
return dictionary;
}
NSArray *uniqueArray(NSArray *anArray)
{
NSMutableArray *copiedArray = [NSMutableArray arrayWithArray:anArray];
for (id object in anArray)
{
[copiedArray removeObjectIdenticalTo:object];
[copiedArray addObject:object];
}
return copiedArray;
}
NSArray *conformanceArray(NSString *aUTI)
{
NSMutableArray *results = [NSMutableArray arrayWithObject:aUTI];
NSDictionary *dictionary = utiDictionary(aUTI);
id conforms = dictionary[(__bridge NSString *)kUTTypeConformsToKey];
// No conformance
if (!conforms) return results;
// Single conformance
if ([conforms isKindOfClass:[NSString class]])
{
[results addObjectsFromArray:conformanceArray(conforms)];
return uniqueArray(results);
}
// Iterate through multiple conformance
if ([conforms isKindOfClass:[NSArray class]])
{
for (NSString *eachUTI in (NSArray *) conforms)
[results addObjectsFromArray:conformanceArray(eachUTI)];
return uniqueArray(results);
}
// Just return the one-item array
return results;
}
NSArray *allExtensions(NSString *aUTI)
{
NSMutableArray *results = [NSMutableArray array];
NSArray *conformance = conformanceArray(aUTI);
for (NSString *eachUTI in conformance)
{
NSDictionary *dictionary = utiDictionary(eachUTI);
NSDictionary *extensions = dictionary[(__bridge NSString *)kUTTypeTagSpecificationKey];
id fileTypes = extensions[(__bridge NSString *)kUTTagClassFilenameExtension];
if ([fileTypes isKindOfClass:[NSArray class]])
[results addObjectsFromArray:(NSArray *) fileTypes];
else if ([fileTypes isKindOfClass:[NSString class]])
[results addObject:(NSString *) fileTypes];
}
return uniqueArray(results);
}
NSArray *allMIMETypes(NSString *aUTI)
{
NSMutableArray *results = [NSMutableArray array];
NSArray *conformance = conformanceArray(aUTI);
for (NSString *eachUTI in conformance)
{
NSDictionary *dictionary = utiDictionary(eachUTI);
NSDictionary *extensions = dictionary[(__bridge NSString *)kUTTypeTagSpecificationKey];
id fileTypes = extensions[(__bridge NSString *)kUTTagClassMIMEType];
if ([fileTypes isKindOfClass:[NSArray class]])
[results addObjectsFromArray:(NSArray *) fileTypes];
else if ([fileTypes isKindOfClass:[NSString class]])
[results addObject:(NSString *) fileTypes];
}
return uniqueArray(results);
}
NSArray *allUTIsForExtension(NSString *ext)
{
NSArray *array = (__bridge_transfer NSArray *) UTTypeCreateAllIdentifiersForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef) ext, NULL);
return array;
}
BOOL pathPointsToLikelyUTIMatch(NSString *path, CFStringRef theUTI)
{
NSString *extension = path.pathExtension;
NSString *preferredUTI = preferredUTIForExtension(extension);
return (UTTypeConformsTo((__bridge CFStringRef) preferredUTI, theUTI));
}
BOOL pathPointsToLikelyImage(NSString *path)
{
return pathPointsToLikelyUTIMatch(path, CFSTR("public.image"));
}
BOOL pathPointsToLikelyAudio(NSString *path)
{
return pathPointsToLikelyUTIMatch(path, CFSTR("public.audio"));
}

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

View File

Before

Width:  |  Height:  |  Size: 223 KiB

After

Width:  |  Height:  |  Size: 223 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,315 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
8E28FC8615CB0CE90010464C /* UTIHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E28FC8515CB0CE90010464C /* UTIHelper.m */; };
8E28FC8C15CB13120010464C /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E28FC8B15CB13120010464C /* MobileCoreServices.framework */; };
8EB9BF0E158B9B4800F96828 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF0D158B9B4800F96828 /* Icon.png */; };
8EB9BF19158B9B7900F96828 /* Default-Landscape@2x~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF10158B9B7900F96828 /* Default-Landscape@2x~ipad.png */; };
8EB9BF1A158B9B7900F96828 /* Default-Landscape~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF11158B9B7900F96828 /* Default-Landscape~ipad.png */; };
8EB9BF1B158B9B7900F96828 /* Default-Portrait@2x~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF12158B9B7900F96828 /* Default-Portrait@2x~ipad.png */; };
8EB9BF1C158B9B7900F96828 /* Default-Portrait~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF13158B9B7900F96828 /* Default-Portrait~ipad.png */; };
8EB9BF1D158B9B7900F96828 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF14158B9B7900F96828 /* Default.png */; };
8EB9BF1E158B9B7900F96828 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF15158B9B7900F96828 /* Default@2x.png */; };
8EB9BF1F158B9B7900F96828 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF16158B9B7900F96828 /* Icon@2x.png */; };
8EB9BF20158B9B7900F96828 /* Icon~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF17158B9B7900F96828 /* Icon~ipad.png */; };
8EB9BF21158B9B7900F96828 /* Icon~ipad@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF18158B9B7900F96828 /* Icon~ipad@2x.png */; };
8EF624E115892BA600A81FD2 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EF624E015892BA600A81FD2 /* UIKit.framework */; };
8EF624E315892BA600A81FD2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EF624E215892BA600A81FD2 /* Foundation.framework */; };
8EF624E515892BA600A81FD2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EF624E415892BA600A81FD2 /* CoreGraphics.framework */; };
8EF624EB15892BA600A81FD2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8EF624E915892BA600A81FD2 /* InfoPlist.strings */; };
8EF624ED15892BA600A81FD2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EF624EC15892BA600A81FD2 /* main.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
8E28FC8415CB0CE90010464C /* UTIHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTIHelper.h; sourceTree = "<group>"; };
8E28FC8515CB0CE90010464C /* UTIHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UTIHelper.m; sourceTree = "<group>"; };
8E28FC8B15CB13120010464C /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
8EB9BF0D158B9B4800F96828 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon.png; path = AppArt/Icon.png; sourceTree = "<group>"; };
8EB9BF10158B9B7900F96828 /* Default-Landscape@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Landscape@2x~ipad.png"; path = "AppArt/Default-Landscape@2x~ipad.png"; sourceTree = "<group>"; };
8EB9BF11158B9B7900F96828 /* Default-Landscape~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Landscape~ipad.png"; path = "AppArt/Default-Landscape~ipad.png"; sourceTree = "<group>"; };
8EB9BF12158B9B7900F96828 /* Default-Portrait@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Portrait@2x~ipad.png"; path = "AppArt/Default-Portrait@2x~ipad.png"; sourceTree = "<group>"; };
8EB9BF13158B9B7900F96828 /* Default-Portrait~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Portrait~ipad.png"; path = "AppArt/Default-Portrait~ipad.png"; sourceTree = "<group>"; };
8EB9BF14158B9B7900F96828 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = AppArt/Default.png; sourceTree = "<group>"; };
8EB9BF15158B9B7900F96828 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "AppArt/Default@2x.png"; sourceTree = "<group>"; };
8EB9BF16158B9B7900F96828 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon@2x.png"; path = "AppArt/Icon@2x.png"; sourceTree = "<group>"; };
8EB9BF17158B9B7900F96828 /* Icon~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon~ipad.png"; path = "AppArt/Icon~ipad.png"; sourceTree = "<group>"; };
8EB9BF18158B9B7900F96828 /* Icon~ipad@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon~ipad@2x.png"; path = "AppArt/Icon~ipad@2x.png"; sourceTree = "<group>"; };
8EE9B88F15B746C400F4FCCA /* Utility.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Utility.h; sourceTree = "<group>"; };
8EF624DC15892BA600A81FD2 /* HelloWorld.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorld.app; sourceTree = BUILT_PRODUCTS_DIR; };
8EF624E015892BA600A81FD2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
8EF624E215892BA600A81FD2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
8EF624E415892BA600A81FD2 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
8EF624E815892BA600A81FD2 /* HelloWorld-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HelloWorld-Info.plist"; sourceTree = "<group>"; };
8EF624EA15892BA600A81FD2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
8EF624EC15892BA600A81FD2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = main.m; path = HelloWorld/main.m; sourceTree = "<group>"; };
8EF624EE15892BA600A81FD2 /* HelloWorld-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "HelloWorld-Prefix.pch"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8EF624D915892BA600A81FD2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8E28FC8C15CB13120010464C /* MobileCoreServices.framework in Frameworks */,
8EF624E115892BA600A81FD2 /* UIKit.framework in Frameworks */,
8EF624E315892BA600A81FD2 /* Foundation.framework in Frameworks */,
8EF624E515892BA600A81FD2 /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
8EF624D115892BA600A81FD2 = {
isa = PBXGroup;
children = (
8EF624EC15892BA600A81FD2 /* main.m */,
8E28FC8415CB0CE90010464C /* UTIHelper.h */,
8E28FC8515CB0CE90010464C /* UTIHelper.m */,
8EF624E715892BA600A81FD2 /* Supporting Files */,
8EF624DF15892BA600A81FD2 /* Frameworks */,
8EF624DD15892BA600A81FD2 /* Products */,
);
sourceTree = "<group>";
};
8EF624DD15892BA600A81FD2 /* Products */ = {
isa = PBXGroup;
children = (
8EF624DC15892BA600A81FD2 /* HelloWorld.app */,
);
name = Products;
sourceTree = "<group>";
};
8EF624DF15892BA600A81FD2 /* Frameworks */ = {
isa = PBXGroup;
children = (
8E28FC8B15CB13120010464C /* MobileCoreServices.framework */,
8EF624E015892BA600A81FD2 /* UIKit.framework */,
8EF624E215892BA600A81FD2 /* Foundation.framework */,
8EF624E415892BA600A81FD2 /* CoreGraphics.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
8EF624E715892BA600A81FD2 /* Supporting Files */ = {
isa = PBXGroup;
children = (
8EE9B88F15B746C400F4FCCA /* Utility.h */,
8EF6250B15892CDA00A81FD2 /* System Art */,
8EF624E815892BA600A81FD2 /* HelloWorld-Info.plist */,
8EF624E915892BA600A81FD2 /* InfoPlist.strings */,
8EF624EE15892BA600A81FD2 /* HelloWorld-Prefix.pch */,
);
name = "Supporting Files";
path = HelloWorld;
sourceTree = "<group>";
};
8EF6250B15892CDA00A81FD2 /* System Art */ = {
isa = PBXGroup;
children = (
8EB9BF0D158B9B4800F96828 /* Icon.png */,
8EB9BF10158B9B7900F96828 /* Default-Landscape@2x~ipad.png */,
8EB9BF11158B9B7900F96828 /* Default-Landscape~ipad.png */,
8EB9BF12158B9B7900F96828 /* Default-Portrait@2x~ipad.png */,
8EB9BF13158B9B7900F96828 /* Default-Portrait~ipad.png */,
8EB9BF14158B9B7900F96828 /* Default.png */,
8EB9BF15158B9B7900F96828 /* Default@2x.png */,
8EB9BF16158B9B7900F96828 /* Icon@2x.png */,
8EB9BF17158B9B7900F96828 /* Icon~ipad.png */,
8EB9BF18158B9B7900F96828 /* Icon~ipad@2x.png */,
);
name = "System Art";
path = ..;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
8EF624DB15892BA600A81FD2 /* HelloWorld */ = {
isa = PBXNativeTarget;
buildConfigurationList = 8EF624F415892BA600A81FD2 /* Build configuration list for PBXNativeTarget "HelloWorld" */;
buildPhases = (
8EF624D815892BA600A81FD2 /* Sources */,
8EF624D915892BA600A81FD2 /* Frameworks */,
8EF624DA15892BA600A81FD2 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = HelloWorld;
productName = HelloWorld;
productReference = 8EF624DC15892BA600A81FD2 /* HelloWorld.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
8EF624D315892BA600A81FD2 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0450;
ORGANIZATIONNAME = "Erica Sadun";
};
buildConfigurationList = 8EF624D615892BA600A81FD2 /* Build configuration list for PBXProject "HelloWorld" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 8EF624D115892BA600A81FD2;
productRefGroup = 8EF624DD15892BA600A81FD2 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
8EF624DB15892BA600A81FD2 /* HelloWorld */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
8EF624DA15892BA600A81FD2 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8EF624EB15892BA600A81FD2 /* InfoPlist.strings in Resources */,
8EB9BF0E158B9B4800F96828 /* Icon.png in Resources */,
8EB9BF19158B9B7900F96828 /* Default-Landscape@2x~ipad.png in Resources */,
8EB9BF1A158B9B7900F96828 /* Default-Landscape~ipad.png in Resources */,
8EB9BF1B158B9B7900F96828 /* Default-Portrait@2x~ipad.png in Resources */,
8EB9BF1C158B9B7900F96828 /* Default-Portrait~ipad.png in Resources */,
8EB9BF1D158B9B7900F96828 /* Default.png in Resources */,
8EB9BF1E158B9B7900F96828 /* Default@2x.png in Resources */,
8EB9BF1F158B9B7900F96828 /* Icon@2x.png in Resources */,
8EB9BF20158B9B7900F96828 /* Icon~ipad.png in Resources */,
8EB9BF21158B9B7900F96828 /* Icon~ipad@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
8EF624D815892BA600A81FD2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8EF624ED15892BA600A81FD2 /* main.m in Sources */,
8E28FC8615CB0CE90010464C /* UTIHelper.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
8EF624E915892BA600A81FD2 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
8EF624EA15892BA600A81FD2 /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
8EF624F215892BA600A81FD2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = 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_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
8EF624F315892BA600A81FD2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
8EF624F515892BA600A81FD2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "HelloWorld/HelloWorld-Prefix.pch";
INFOPLIST_FILE = "HelloWorld/HelloWorld-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
8EF624F615892BA600A81FD2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "HelloWorld/HelloWorld-Prefix.pch";
INFOPLIST_FILE = "HelloWorld/HelloWorld-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
8EF624D615892BA600A81FD2 /* Build configuration list for PBXProject "HelloWorld" */ = {
isa = XCConfigurationList;
buildConfigurations = (
8EF624F215892BA600A81FD2 /* Debug */,
8EF624F315892BA600A81FD2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
8EF624F415892BA600A81FD2 /* Build configuration list for PBXNativeTarget "HelloWorld" */ = {
isa = XCConfigurationList;
buildConfigurations = (
8EF624F515892BA600A81FD2 /* Debug */,
8EF624F615892BA600A81FD2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 8EF624D315892BA600A81FD2 /* Project object */;
}

View File

@@ -0,0 +1,64 @@
<?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>CFBundleIcons</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>Icon.png</string>
<string>Icon@2x.png</string>
<string>Default.png</string>
<string>Default@2x.png</string>
<string>Icon~ipad.png</string>
<string>Icon~ipad@2x.png</string>
<string>Default-Portrait~ipad.png</string>
<string>Default-Portrait@2x~ipad.png</string>
<string>Default-Landscape~ipad.png</string>
<string>Default-Landscape@2x~ipad.png</string>
</array>
</dict>
</dict>
<key>CFBundleIdentifier</key>
<string>com.sadun.${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>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>

View File

@@ -0,0 +1,83 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#pragma mark - Cookbook
#define COOKBOOK_PURPLE_COLOR [UIColor colorWithRed:0.20392f green:0.19607f blue:0.61176f alpha:1.0f]
#pragma mark - Bar Buttons
#define BARBUTTON(TITLE, SELECTOR) [[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self action:SELECTOR]
#define SYSBARBUTTON(ITEM, SELECTOR) [[UIBarButtonItem alloc] initWithBarButtonSystemItem:ITEM target:self action:SELECTOR]
#define IMGBARBUTTON(IMAGE, SELECTOR) [[UIBarButtonItem alloc] initWithImage:IMAGE style:UIBarButtonItemStylePlain target:self action:SELECTOR]
#define CUSTOMBARBUTTON(VIEW) [[UIBarButtonItem alloc] initWithCustomView:VIEW]
#define SYSBARBUTTON_TARGET(ITEM, TARGET, SELECTOR) [[UIBarButtonItem alloc] initWithBarButtonSystemItem:ITEM target:TARGET action:SELECTOR]
#define BARBUTTON_TARGET(TITLE, TARGET, SELECTOR) [[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:TARGET action:SELECTOR]
#pragma mark - Platform
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#pragma mark - Orientation
// #define IS_PORTRAIT UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation)
// #define IS_PORTRAIT UIDeviceOrientationIsPortrait(self.interfaceOrientation)
// #define IS_PORTRAIT UIDeviceOrientationIsPortrait([UIDevice currentDevice].orientation) || UIDeviceOrientationIsPortrait(self.interfaceOrientation)
#pragma mark - Debug
#define BOOL_CHECK(TITLE, CHECK_ITEM) printf("%s: %s\n", TITLE, (CHECK_ITEM) ? "Yes" : "No")
#pragma mark - Geometry
#define RECTCENTER(RECT) CGPointMake(CGRectGetMidX(RECT), CGRectGetMidY(RECT))
#define RESIZABLE(VIEW) [VIEW setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth]
#pragma mark - Strings
#define STREQ(STRING1, STRING2) ([STRING1 caseInsensitiveCompare:STRING2] == NSOrderedSame)
#define PREFIXED(STRING1, STRING2) ([[STRING1 uppercaseString] hasPrefix:[STRING2 uppercaseString]])
#define TRIMSTRING(STRING) ([STRING stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]])
#define STRDATA(STRING) ([STRING dataUsingEncoding:NSUTF8StringEncoding])
#define DATASTR(DATA) ([[NSString alloc] initWithData:DATA encoding:NSUTF8StringEncoding])
#pragma mark - Constraints
#define PREPCONSTRAINTS(VIEW) [VIEW setTranslatesAutoresizingMaskIntoConstraints:NO]
#define CONSTRAIN(PARENT, VIEW, FORMAT) [PARENT addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:(FORMAT) options:0 metrics:nil views:NSDictionaryOfVariableBindings(VIEW)]]
#define CONSTRAIN_VIEWS(PARENT, FORMAT, BINDINGS) [PARENT addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:(FORMAT) options:0 metrics:nil views:BINDINGS]]
// Stretch across axes
#define STRETCH_VIEW_H(PARENT, VIEW) CONSTRAIN(PARENT, VIEW, @"H:|["#VIEW"(>=0)]|")
#define STRETCH_VIEW_V(PARENT, VIEW) CONSTRAIN(PARENT, VIEW, @"V:|["#VIEW"(>=0)]|")
#define STRETCH_VIEW(PARENT, VIEW) {STRETCH_VIEW_H(PARENT, VIEW); STRETCH_VIEW_V(PARENT, VIEW);}
// Center along axes
#define CENTER_VIEW_H(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeCenterX multiplier:1.0f constant:0.0f]]
#define CENTER_VIEW_V(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeCenterY multiplier:1.0f constant:0.0f]]
#define CENTER_VIEW(PARENT, VIEW) {CENTER_VIEW_H(PARENT, VIEW); CENTER_VIEW_V(PARENT, VIEW);}
// Align to parent
#define ALIGN_VIEW_LEFT(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeLeft multiplier:1.0f constant:0.0f]]
#define ALIGN_VIEW_RIGHT(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeRight multiplier:1.0f constant:0.0f]]
#define ALIGN_VIEW_TOP(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeTop multiplier:1.0f constant:0.0f]]
#define ALIGN_VIEW_BOTTOM(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeBottom multiplier:1.0f constant:0.0f]]
// Set Size
#define CONSTRAIN_WIDTH(VIEW, WIDTH) CONSTRAIN(VIEW, VIEW, @"H:["#VIEW"(=="#WIDTH")]")
#define CONSTRAIN_HEIGHT(VIEW, HEIGHT) CONSTRAIN(VIEW, VIEW, @"V:["#VIEW"(=="#HEIGHT")]")
#define CONSTRAIN_SIZE(VIEW, HEIGHT, WIDTH) {CONSTRAIN_WIDTH(VIEW, WIDTH); CONSTRAIN_HEIGHT(VIEW, HEIGHT);}
// Set Aspect
#define CONSTRAIN_ASPECT(VIEW, ASPECT) [VIEW addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:VIEW attribute:NSLayoutAttributeHeight multiplier:(ASPECT) constant:0.0f]]
// Order items
#define CONSTRAIN_ORDER_H(PARENT, VIEW1, VIEW2) [PARENT addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:(@"H:["#VIEW1"]->=0-["#VIEW2"]") options:0 metrics:nil views:NSDictionaryOfVariableBindings(VIEW1, VIEW2)]]
#define CONSTRAIN_ORDER_V(PARENT, VIEW1, VIEW2) [PARENT addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:(@"V:["#VIEW1"]->=0-["#VIEW2"]") options:0 metrics:nil views:NSDictionaryOfVariableBindings(VIEW1, VIEW2)]]
#pragma mark - Util
// Bail with complaint
#define COMPLAIN_AND_BAIL(_COMPLAINT_, _ARG_) {NSLog(_COMPLAINT_, _ARG_); return;}
#define COMPLAIN_AND_BAIL_NIL(_COMPLAINT_, _ARG_) {NSLog(_COMPLAINT_, _ARG_); return nil;}
// Math
#define SIGN(_NUM_) ((_NUM_ < 0) ? (-1) : 1)

View File

@@ -0,0 +1,81 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#import <UIKit/UIKit.h>
#import "UTIHelper.h"
#import "Utility.h"
@interface TestBedViewController : UIViewController <UITextViewDelegate>
@end
@implementation TestBedViewController
{
UITextView *textView;
BOOL enableWatcher;
}
- (void) updatePasteboard
{
if (enableWatcher)
[UIPasteboard generalPasteboard].string = textView.text;
}
- (void)textViewDidChange:(UITextView *)textView
{
[self updatePasteboard];
}
- (void) toggle: (UIBarButtonItem *) bbi
{
enableWatcher = !enableWatcher;
bbi.title = enableWatcher ? @"Stop Watching" : @"Watch";
}
- (void) loadView
{
[super loadView];
self.view.backgroundColor = [UIColor whiteColor];
textView = [[UITextView alloc] initWithFrame:CGRectZero];
textView.delegate = self;
[self updatePasteboard];
[self.view addSubview:textView];
PREPCONSTRAINTS(textView);
STRETCH_VIEW(self.view, textView);
self.navigationItem.rightBarButtonItem = BARBUTTON(@"Watch", @selector(toggle:));
NSLog(@"%@", conformanceArray(allUTIsForExtension(@"JPEG")[0]));
}
@end
#pragma mark - Application Setup -
@interface TestBedAppDelegate : NSObject <UIApplicationDelegate>
@end
@implementation TestBedAppDelegate
{
UIWindow *window;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// [application setStatusBarHidden:YES];
[[UINavigationBar appearance] setTintColor:COOKBOOK_PURPLE_COLOR];
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
TestBedViewController *tbvc = [[TestBedViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:tbvc];
window.rootViewController = nav;
[window makeKeyAndVisible];
return YES;
}
@end
int main(int argc, char *argv[]) {
@autoreleasepool {
int retVal = UIApplicationMain(argc, argv, nil, @"TestBedAppDelegate");
return retVal;
}
}

View File

@@ -0,0 +1,29 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 5.x Edition
BSD License, Use at your own risk
*/
#import <Foundation/Foundation.h>
#import <MobileCoreServices/MobileCoreServices.h>
NSString *uuid();
NSString *preferredExtensionForUTI(NSString *aUTI);
NSString *preferredMimeTypeForUTI(NSString *aUTI);
NSString *preferredUTIForExtension(NSString *ext);
NSString *preferredUTIForMIMEType(NSString *mime);
NSArray *allExtensions(NSString *aUTI);
NSArray *allMIMETypes(NSString *aUTI);
NSDictionary *utiDictionary(NSString *aUTI);
NSArray *conformanceArray(NSString *aUTI);
NSArray *allUTIsForExtension(NSString *ext);
BOOL pathPointsToLikelyUTIMatch(NSString *path, CFStringRef theUTI);
// You can add any number of these as desired.
BOOL pathPointsToLikelyImage(NSString *path);
BOOL pathPointsToLikelyAudio(NSString *path);

View File

@@ -0,0 +1,153 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 5.x Edition
BSD License, Use at your own risk
*/
#import "UTIHelper.h"
NSString *uuid()
{
CFUUIDRef theUUID = CFUUIDCreate(NULL);
NSString *uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(NULL, theUUID);
CFRelease(theUUID);
return uuidString;
}
NSString *preferredExtensionForUTI(NSString *aUTI)
{
CFStringRef theUTI = (__bridge CFStringRef) aUTI;
CFStringRef results = UTTypeCopyPreferredTagWithClass(theUTI, kUTTagClassFilenameExtension);
return (__bridge_transfer NSString *)results;
}
NSString *preferredMimeTypeForUTI(NSString *aUTI)
{
CFStringRef theUTI = (__bridge CFStringRef) aUTI;
CFStringRef results = UTTypeCopyPreferredTagWithClass(theUTI, kUTTagClassMIMEType);
return (__bridge_transfer NSString *)results;
}
NSString *preferredUTIForExtension(NSString *ext)
{
// Request the UTI via the file extension
NSString *theUTI = (__bridge_transfer NSString *) UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef) ext, NULL);
return theUTI;
}
NSString *preferredUTIForMIMEType(NSString *mime)
{
// Request the UTI via the file extension
NSString *theUTI = (__bridge_transfer NSString *) UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, (__bridge CFStringRef) mime, NULL);
return theUTI;
}
NSDictionary *utiDictionary(NSString *aUTI)
{
NSDictionary *dictionary = (__bridge_transfer NSDictionary *)UTTypeCopyDeclaration((__bridge CFStringRef) aUTI);
return dictionary;
}
NSArray *uniqueArray(NSArray *anArray)
{
NSMutableArray *copiedArray = [NSMutableArray arrayWithArray:anArray];
for (id object in anArray)
{
[copiedArray removeObjectIdenticalTo:object];
[copiedArray addObject:object];
}
return copiedArray;
}
NSArray *conformanceArray(NSString *aUTI)
{
NSMutableArray *results = [NSMutableArray arrayWithObject:aUTI];
NSDictionary *dictionary = utiDictionary(aUTI);
id conforms = dictionary[(__bridge NSString *)kUTTypeConformsToKey];
// No conformance
if (!conforms) return results;
// Single conformance
if ([conforms isKindOfClass:[NSString class]])
{
[results addObjectsFromArray:conformanceArray(conforms)];
return uniqueArray(results);
}
// Iterate through multiple conformance
if ([conforms isKindOfClass:[NSArray class]])
{
for (NSString *eachUTI in (NSArray *) conforms)
[results addObjectsFromArray:conformanceArray(eachUTI)];
return uniqueArray(results);
}
// Just return the one-item array
return results;
}
NSArray *allExtensions(NSString *aUTI)
{
NSMutableArray *results = [NSMutableArray array];
NSArray *conformance = conformanceArray(aUTI);
for (NSString *eachUTI in conformance)
{
NSDictionary *dictionary = utiDictionary(eachUTI);
NSDictionary *extensions = dictionary[(__bridge NSString *)kUTTypeTagSpecificationKey];
id fileTypes = extensions[(__bridge NSString *)kUTTagClassFilenameExtension];
if ([fileTypes isKindOfClass:[NSArray class]])
[results addObjectsFromArray:(NSArray *) fileTypes];
else if ([fileTypes isKindOfClass:[NSString class]])
[results addObject:(NSString *) fileTypes];
}
return uniqueArray(results);
}
NSArray *allMIMETypes(NSString *aUTI)
{
NSMutableArray *results = [NSMutableArray array];
NSArray *conformance = conformanceArray(aUTI);
for (NSString *eachUTI in conformance)
{
NSDictionary *dictionary = utiDictionary(eachUTI);
NSDictionary *extensions = dictionary[(__bridge NSString *)kUTTypeTagSpecificationKey];
id fileTypes = extensions[(__bridge NSString *)kUTTagClassMIMEType];
if ([fileTypes isKindOfClass:[NSArray class]])
[results addObjectsFromArray:(NSArray *) fileTypes];
else if ([fileTypes isKindOfClass:[NSString class]])
[results addObject:(NSString *) fileTypes];
}
return uniqueArray(results);
}
NSArray *allUTIsForExtension(NSString *ext)
{
NSArray *array = (__bridge_transfer NSArray *) UTTypeCreateAllIdentifiersForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef) ext, NULL);
return array;
}
BOOL pathPointsToLikelyUTIMatch(NSString *path, CFStringRef theUTI)
{
NSString *extension = path.pathExtension;
NSString *preferredUTI = preferredUTIForExtension(extension);
return (UTTypeConformsTo((__bridge CFStringRef) preferredUTI, theUTI));
}
BOOL pathPointsToLikelyImage(NSString *path)
{
return pathPointsToLikelyUTIMatch(path, CFSTR("public.image"));
}
BOOL pathPointsToLikelyAudio(NSString *path)
{
return pathPointsToLikelyUTIMatch(path, CFSTR("public.audio"));
}

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 69 KiB

After

Width:  |  Height:  |  Size: 69 KiB

View File

Before

Width:  |  Height:  |  Size: 223 KiB

After

Width:  |  Height:  |  Size: 223 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 4.0 KiB

After

Width:  |  Height:  |  Size: 4.0 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@@ -0,0 +1,10 @@
#define kDocumentChanged @"DocumentsFolderContentsDidChangeNotification"
@interface DocWatchHelper : NSObject
{
CFFileDescriptorRef kqref;
CFRunLoopSourceRef rls;
}
@property (strong) NSString *path;
+ (id) watcherForPath: (NSString *) aPath;
@end

View File

@@ -0,0 +1,80 @@
#import "DocWatchHelper.h"
#import <fcntl.h>
#import <sys/event.h>
@implementation DocWatchHelper
@synthesize path;
- (void)kqueueFired
{
int kq;
struct kevent event;
struct timespec timeout = { 0, 0 };
int eventCount;
kq = CFFileDescriptorGetNativeDescriptor(self->kqref);
assert(kq >= 0);
eventCount = kevent(kq, NULL, 0, &event, 1, &timeout);
assert( (eventCount >= 0) && (eventCount < 2) );
if (eventCount == 1)
[[NSNotificationCenter defaultCenter] postNotificationName:kDocumentChanged object:self];
CFFileDescriptorEnableCallBacks(self->kqref, kCFFileDescriptorReadCallBack);
}
static void KQCallback(CFFileDescriptorRef kqRef, CFOptionFlags callBackTypes, void *info)
{
DocWatchHelper *helper = (DocWatchHelper *)(__bridge id)(CFTypeRef) info;
[helper kqueueFired];
}
- (void) beginGeneratingDocumentNotificationsInPath: (NSString *) docPath
{
int dirFD;
int kq;
int retVal;
struct kevent eventToAdd;
CFFileDescriptorContext context = { 0, (void *)(__bridge CFTypeRef) self, NULL, NULL, NULL };
dirFD = open([docPath fileSystemRepresentation], O_EVTONLY);
assert(dirFD >= 0);
kq = kqueue();
assert(kq >= 0);
eventToAdd.ident = dirFD;
eventToAdd.filter = EVFILT_VNODE;
eventToAdd.flags = EV_ADD | EV_CLEAR;
eventToAdd.fflags = NOTE_WRITE;
eventToAdd.data = 0;
eventToAdd.udata = NULL;
retVal = kevent(kq, &eventToAdd, 1, NULL, 0, NULL);
assert(retVal == 0);
self->kqref = CFFileDescriptorCreate(NULL, kq, true, KQCallback, &context);
rls = CFFileDescriptorCreateRunLoopSource(NULL, self->kqref, 0);
assert(rls != NULL);
CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode);
CFRelease(rls);
CFFileDescriptorEnableCallBacks(self->kqref, kCFFileDescriptorReadCallBack);
}
- (void) dealloc
{
self.path = nil;
CFRunLoopRemoveSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode);
CFFileDescriptorDisableCallBacks(self->kqref, kCFFileDescriptorReadCallBack);
}
+ (id) watcherForPath: (NSString *) aPath
{
DocWatchHelper *watcher = [[self alloc] init];
watcher.path = aPath;
[watcher beginGeneratingDocumentNotificationsInPath:aPath];
return watcher;
}
@end

View File

@@ -0,0 +1,323 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objects = {
/* Begin PBXBuildFile section */
8E28FC9615CB21280010464C /* DocWatchHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E28FC9315CB21280010464C /* DocWatchHelper.m */; };
8EB9BF0E158B9B4800F96828 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF0D158B9B4800F96828 /* Icon.png */; };
8EB9BF19158B9B7900F96828 /* Default-Landscape@2x~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF10158B9B7900F96828 /* Default-Landscape@2x~ipad.png */; };
8EB9BF1A158B9B7900F96828 /* Default-Landscape~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF11158B9B7900F96828 /* Default-Landscape~ipad.png */; };
8EB9BF1B158B9B7900F96828 /* Default-Portrait@2x~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF12158B9B7900F96828 /* Default-Portrait@2x~ipad.png */; };
8EB9BF1C158B9B7900F96828 /* Default-Portrait~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF13158B9B7900F96828 /* Default-Portrait~ipad.png */; };
8EB9BF1D158B9B7900F96828 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF14158B9B7900F96828 /* Default.png */; };
8EB9BF1E158B9B7900F96828 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF15158B9B7900F96828 /* Default@2x.png */; };
8EB9BF1F158B9B7900F96828 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF16158B9B7900F96828 /* Icon@2x.png */; };
8EB9BF20158B9B7900F96828 /* Icon~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF17158B9B7900F96828 /* Icon~ipad.png */; };
8EB9BF21158B9B7900F96828 /* Icon~ipad@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 8EB9BF18158B9B7900F96828 /* Icon~ipad@2x.png */; };
8EC38FE015B38D0A0034B7D1 /* Utility.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EC38FDF15B38D0A0034B7D1 /* Utility.m */; };
8EF624E115892BA600A81FD2 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EF624E015892BA600A81FD2 /* UIKit.framework */; };
8EF624E315892BA600A81FD2 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EF624E215892BA600A81FD2 /* Foundation.framework */; };
8EF624E515892BA600A81FD2 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8EF624E415892BA600A81FD2 /* CoreGraphics.framework */; };
8EF624EB15892BA600A81FD2 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8EF624E915892BA600A81FD2 /* InfoPlist.strings */; };
8EF624ED15892BA600A81FD2 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EF624EC15892BA600A81FD2 /* main.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
8E28FC9215CB21280010464C /* DocWatchHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocWatchHelper.h; sourceTree = "<group>"; };
8E28FC9315CB21280010464C /* DocWatchHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DocWatchHelper.m; sourceTree = "<group>"; };
8EB9BF0D158B9B4800F96828 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Icon.png; path = AppArt/Icon.png; sourceTree = "<group>"; };
8EB9BF10158B9B7900F96828 /* Default-Landscape@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Landscape@2x~ipad.png"; path = "AppArt/Default-Landscape@2x~ipad.png"; sourceTree = "<group>"; };
8EB9BF11158B9B7900F96828 /* Default-Landscape~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Landscape~ipad.png"; path = "AppArt/Default-Landscape~ipad.png"; sourceTree = "<group>"; };
8EB9BF12158B9B7900F96828 /* Default-Portrait@2x~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Portrait@2x~ipad.png"; path = "AppArt/Default-Portrait@2x~ipad.png"; sourceTree = "<group>"; };
8EB9BF13158B9B7900F96828 /* Default-Portrait~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-Portrait~ipad.png"; path = "AppArt/Default-Portrait~ipad.png"; sourceTree = "<group>"; };
8EB9BF14158B9B7900F96828 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = AppArt/Default.png; sourceTree = "<group>"; };
8EB9BF15158B9B7900F96828 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "AppArt/Default@2x.png"; sourceTree = "<group>"; };
8EB9BF16158B9B7900F96828 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon@2x.png"; path = "AppArt/Icon@2x.png"; sourceTree = "<group>"; };
8EB9BF17158B9B7900F96828 /* Icon~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon~ipad.png"; path = "AppArt/Icon~ipad.png"; sourceTree = "<group>"; };
8EB9BF18158B9B7900F96828 /* Icon~ipad@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon~ipad@2x.png"; path = "AppArt/Icon~ipad@2x.png"; sourceTree = "<group>"; };
8EC38FDE15B38D0A0034B7D1 /* Utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Utility.h; sourceTree = "<group>"; };
8EC38FDF15B38D0A0034B7D1 /* Utility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Utility.m; sourceTree = "<group>"; };
8EF624DC15892BA600A81FD2 /* HelloWorld.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorld.app; sourceTree = BUILT_PRODUCTS_DIR; };
8EF624E015892BA600A81FD2 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
8EF624E215892BA600A81FD2 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
8EF624E415892BA600A81FD2 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
8EF624E815892BA600A81FD2 /* HelloWorld-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "HelloWorld-Info.plist"; sourceTree = "<group>"; };
8EF624EA15892BA600A81FD2 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
8EF624EC15892BA600A81FD2 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = main.m; path = HelloWorld/main.m; sourceTree = "<group>"; };
8EF624EE15892BA600A81FD2 /* HelloWorld-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "HelloWorld-Prefix.pch"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
8EF624D915892BA600A81FD2 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8EF624E115892BA600A81FD2 /* UIKit.framework in Frameworks */,
8EF624E315892BA600A81FD2 /* Foundation.framework in Frameworks */,
8EF624E515892BA600A81FD2 /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
8EC38FDD15B38D0A0034B7D1 /* Utility */ = {
isa = PBXGroup;
children = (
8EC38FDE15B38D0A0034B7D1 /* Utility.h */,
8EC38FDF15B38D0A0034B7D1 /* Utility.m */,
);
path = Utility;
sourceTree = "<group>";
};
8EF624D115892BA600A81FD2 = {
isa = PBXGroup;
children = (
8EF624EC15892BA600A81FD2 /* main.m */,
8E28FC9215CB21280010464C /* DocWatchHelper.h */,
8E28FC9315CB21280010464C /* DocWatchHelper.m */,
8EF624E715892BA600A81FD2 /* Supporting Files */,
8EF624DF15892BA600A81FD2 /* Frameworks */,
8EF624DD15892BA600A81FD2 /* Products */,
);
sourceTree = "<group>";
};
8EF624DD15892BA600A81FD2 /* Products */ = {
isa = PBXGroup;
children = (
8EF624DC15892BA600A81FD2 /* HelloWorld.app */,
);
name = Products;
sourceTree = "<group>";
};
8EF624DF15892BA600A81FD2 /* Frameworks */ = {
isa = PBXGroup;
children = (
8EF624E015892BA600A81FD2 /* UIKit.framework */,
8EF624E215892BA600A81FD2 /* Foundation.framework */,
8EF624E415892BA600A81FD2 /* CoreGraphics.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
8EF624E715892BA600A81FD2 /* Supporting Files */ = {
isa = PBXGroup;
children = (
8EC38FDD15B38D0A0034B7D1 /* Utility */,
8EF6250B15892CDA00A81FD2 /* System Art */,
8EF624E815892BA600A81FD2 /* HelloWorld-Info.plist */,
8EF624E915892BA600A81FD2 /* InfoPlist.strings */,
8EF624EE15892BA600A81FD2 /* HelloWorld-Prefix.pch */,
);
name = "Supporting Files";
path = HelloWorld;
sourceTree = "<group>";
};
8EF6250B15892CDA00A81FD2 /* System Art */ = {
isa = PBXGroup;
children = (
8EB9BF0D158B9B4800F96828 /* Icon.png */,
8EB9BF10158B9B7900F96828 /* Default-Landscape@2x~ipad.png */,
8EB9BF11158B9B7900F96828 /* Default-Landscape~ipad.png */,
8EB9BF12158B9B7900F96828 /* Default-Portrait@2x~ipad.png */,
8EB9BF13158B9B7900F96828 /* Default-Portrait~ipad.png */,
8EB9BF14158B9B7900F96828 /* Default.png */,
8EB9BF15158B9B7900F96828 /* Default@2x.png */,
8EB9BF16158B9B7900F96828 /* Icon@2x.png */,
8EB9BF17158B9B7900F96828 /* Icon~ipad.png */,
8EB9BF18158B9B7900F96828 /* Icon~ipad@2x.png */,
);
name = "System Art";
path = ..;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
8EF624DB15892BA600A81FD2 /* HelloWorld */ = {
isa = PBXNativeTarget;
buildConfigurationList = 8EF624F415892BA600A81FD2 /* Build configuration list for PBXNativeTarget "HelloWorld" */;
buildPhases = (
8EF624D815892BA600A81FD2 /* Sources */,
8EF624D915892BA600A81FD2 /* Frameworks */,
8EF624DA15892BA600A81FD2 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = HelloWorld;
productName = HelloWorld;
productReference = 8EF624DC15892BA600A81FD2 /* HelloWorld.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
8EF624D315892BA600A81FD2 /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0450;
ORGANIZATIONNAME = "Erica Sadun";
};
buildConfigurationList = 8EF624D615892BA600A81FD2 /* Build configuration list for PBXProject "HelloWorld" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
en,
);
mainGroup = 8EF624D115892BA600A81FD2;
productRefGroup = 8EF624DD15892BA600A81FD2 /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
8EF624DB15892BA600A81FD2 /* HelloWorld */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
8EF624DA15892BA600A81FD2 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8EF624EB15892BA600A81FD2 /* InfoPlist.strings in Resources */,
8EB9BF0E158B9B4800F96828 /* Icon.png in Resources */,
8EB9BF19158B9B7900F96828 /* Default-Landscape@2x~ipad.png in Resources */,
8EB9BF1A158B9B7900F96828 /* Default-Landscape~ipad.png in Resources */,
8EB9BF1B158B9B7900F96828 /* Default-Portrait@2x~ipad.png in Resources */,
8EB9BF1C158B9B7900F96828 /* Default-Portrait~ipad.png in Resources */,
8EB9BF1D158B9B7900F96828 /* Default.png in Resources */,
8EB9BF1E158B9B7900F96828 /* Default@2x.png in Resources */,
8EB9BF1F158B9B7900F96828 /* Icon@2x.png in Resources */,
8EB9BF20158B9B7900F96828 /* Icon~ipad.png in Resources */,
8EB9BF21158B9B7900F96828 /* Icon~ipad@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
8EF624D815892BA600A81FD2 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8EF624ED15892BA600A81FD2 /* main.m in Sources */,
8EC38FE015B38D0A0034B7D1 /* Utility.m in Sources */,
8E28FC9615CB21280010464C /* DocWatchHelper.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin PBXVariantGroup section */
8EF624E915892BA600A81FD2 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
8EF624EA15892BA600A81FD2 /* en */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
8EF624F215892BA600A81FD2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = 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_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
8EF624F315892BA600A81FD2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.0;
OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
SDKROOT = iphoneos;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
};
name = Release;
};
8EF624F515892BA600A81FD2 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "HelloWorld/HelloWorld-Prefix.pch";
INFOPLIST_FILE = "HelloWorld/HelloWorld-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Debug;
};
8EF624F615892BA600A81FD2 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "HelloWorld/HelloWorld-Prefix.pch";
INFOPLIST_FILE = "HelloWorld/HelloWorld-Info.plist";
PRODUCT_NAME = "$(TARGET_NAME)";
WRAPPER_EXTENSION = app;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
8EF624D615892BA600A81FD2 /* Build configuration list for PBXProject "HelloWorld" */ = {
isa = XCConfigurationList;
buildConfigurations = (
8EF624F215892BA600A81FD2 /* Debug */,
8EF624F315892BA600A81FD2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
8EF624F415892BA600A81FD2 /* Build configuration list for PBXNativeTarget "HelloWorld" */ = {
isa = XCConfigurationList;
buildConfigurations = (
8EF624F515892BA600A81FD2 /* Debug */,
8EF624F615892BA600A81FD2 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 8EF624D315892BA600A81FD2 /* Project object */;
}

View File

@@ -0,0 +1,22 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#define COOKBOOK_PURPLE_COLOR [UIColor colorWithRed:0.20392f green:0.19607f blue:0.61176f alpha:1.0f]
#define BARBUTTON(TITLE, SELECTOR) [[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self action:SELECTOR]
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define CONSTRAIN(PARENT, VIEW, FORMAT) [PARENT addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:(FORMAT) options:0 metrics:nil views:NSDictionaryOfVariableBindings(VIEW)]]
#define LEFTH(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeLeft multiplier:1.0f constant:0.0f]];
#define TOPV(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeTop multiplier:1.0f constant:0.0f]];
#define CENTERH(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeCenterX multiplier:1.0f constant:0.0f]];
#define CENTERV(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeCenterY multiplier:1.0f constant:0.0f]];
#define PREPCONSTRAINTS(VIEW) [VIEW setTranslatesAutoresizingMaskIntoConstraints:NO]
UIImage *stringImage(NSString *string, UIFont *aFont, CGFloat inset);

View File

@@ -0,0 +1,37 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
UIImage *stringImage(NSString *string, UIFont *aFont, CGFloat inset)
{
CGSize baseSize = [string sizeWithFont:aFont];
CGSize adjustedSize = CGSizeMake(baseSize.width + inset * 2, baseSize.height + inset * 2);
UIGraphicsBeginImageContext(adjustedSize);
CGContextRef context = UIGraphicsGetCurrentContext();
// Draw white backdrop
CGRect bounds = (CGRect){.size = adjustedSize};
[[UIColor whiteColor] set];
CGContextAddRect(context, bounds);
CGContextFillPath(context);
// Draw a black edge
[[UIColor blackColor] set];
CGContextAddRect(context, bounds);
CGContextSetLineWidth(context, inset);
CGContextStrokePath(context);
// Draw the string in black
CGRect insetBounds = CGRectInset(bounds, inset, inset);
[string drawInRect:insetBounds withFont:aFont lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentCenter];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}

View File

@@ -0,0 +1,94 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#import <UIKit/UIKit.h>
#import "Utility.h"
#import "DocWatchHelper.h"
@interface TestBedViewController : UITableViewController
@end
@implementation TestBedViewController
{
NSArray *items;
DocWatchHelper *helper;
}
// Number of sections
- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView
{
return 1;
}
// Rows per section
- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section
{
return items.count;
}
// Return a cell for the index path
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
cell.textLabel.text = [items objectAtIndex:indexPath.row];
return cell;
}
- (void) scanDocuments
{
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
items = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:path error:nil];
[self.tableView reloadData];
}
// Set up table
- (void) loadView
{
[super loadView];
[self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
[self scanDocuments];
[[NSNotificationCenter defaultCenter] addObserverForName:kDocumentChanged object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification)
{
// Contents changed
[self scanDocuments];
}];
NSString *path = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
helper = [DocWatchHelper watcherForPath:path];
}
@end
#pragma mark -
#pragma mark Application Setup
@interface TestBedAppDelegate : NSObject <UIApplicationDelegate>
@end
@implementation TestBedAppDelegate
{
UIWindow *window;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// [application setStatusBarHidden:YES];
[[UINavigationBar appearance] setTintColor:COOKBOOK_PURPLE_COLOR];
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
TestBedViewController *tbvc = [[TestBedViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:tbvc];
window.rootViewController = nav;
[window makeKeyAndVisible];
return YES;
}
@end
int main(int argc, char *argv[]) {
@autoreleasepool {
int retVal = UIApplicationMain(argc, argv, nil, @"TestBedAppDelegate");
return retVal;
}
}

View File

@@ -0,0 +1,22 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
#define COOKBOOK_PURPLE_COLOR [UIColor colorWithRed:0.20392f green:0.19607f blue:0.61176f alpha:1.0f]
#define BARBUTTON(TITLE, SELECTOR) [[UIBarButtonItem alloc] initWithTitle:TITLE style:UIBarButtonItemStylePlain target:self action:SELECTOR]
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define CONSTRAIN(PARENT, VIEW, FORMAT) [PARENT addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:(FORMAT) options:0 metrics:nil views:NSDictionaryOfVariableBindings(VIEW)]]
#define LEFTH(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeLeft multiplier:1.0f constant:0.0f]];
#define TOPV(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeTop multiplier:1.0f constant:0.0f]];
#define CENTERH(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeCenterX multiplier:1.0f constant:0.0f]];
#define CENTERV(PARENT, VIEW) [PARENT addConstraint:[NSLayoutConstraint constraintWithItem:VIEW attribute: NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:PARENT attribute:NSLayoutAttributeCenterY multiplier:1.0f constant:0.0f]];
#define PREPCONSTRAINTS(VIEW) [VIEW setTranslatesAutoresizingMaskIntoConstraints:NO]
UIImage *stringImage(NSString *string, UIFont *aFont, CGFloat inset);

View File

@@ -0,0 +1,37 @@
/*
Erica Sadun, http://ericasadun.com
iPhone Developer's Cookbook, 6.x Edition
BSD License, Use at your own risk
*/
UIImage *stringImage(NSString *string, UIFont *aFont, CGFloat inset)
{
CGSize baseSize = [string sizeWithFont:aFont];
CGSize adjustedSize = CGSizeMake(baseSize.width + inset * 2, baseSize.height + inset * 2);
UIGraphicsBeginImageContext(adjustedSize);
CGContextRef context = UIGraphicsGetCurrentContext();
// Draw white backdrop
CGRect bounds = (CGRect){.size = adjustedSize};
[[UIColor whiteColor] set];
CGContextAddRect(context, bounds);
CGContextFillPath(context);
// Draw a black edge
[[UIColor blackColor] set];
CGContextAddRect(context, bounds);
CGContextSetLineWidth(context, inset);
CGContextStrokePath(context);
// Draw the string in black
CGRect insetBounds = CGRectInset(bounds, inset, inset);
[string drawInRect:insetBounds withFont:aFont lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentCenter];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}

Some files were not shown because too many files have changed in this diff Show More