├── .gitattributes ├── .gitignore ├── LICENSE ├── ObjectToXPC.xcodeproj └── project.pbxproj ├── ObjectToXPC ├── InfoPlist.strings ├── NSArray+CDXPC.h ├── NSArray+CDXPC.m ├── NSData+CDXPC.h ├── NSData+CDXPC.m ├── NSDate+CDXPC.h ├── NSDate+CDXPC.m ├── NSDictionary+CDXPC.h ├── NSDictionary+CDXPC.m ├── NSNull+CDXPC.h ├── NSNull+CDXPC.m ├── NSNumber+CDXPC.h ├── NSNumber+CDXPC.m ├── NSString+CDXPC.h ├── NSString+CDXPC.m ├── ObjectToXPC-Info.plist ├── ObjectToXPC-OSX-Prefix.pch ├── ObjectToXPC-Prefix.pch ├── ObjectToXPC-Private.h └── ObjectToXPC.h ├── README.mdown ├── TODO.mdown └── UnitTests ├── ObjectToXPC-Tests-Info.plist ├── UnitTests.h ├── UnitTests.m └── en.lproj └── InfoPlist.strings /.gitattributes: -------------------------------------------------------------------------------- 1 | *.m diff=objc 2 | *.mm diff=objc 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .VolumeIcon.icns 3 | .fseventsd 4 | *.swp 5 | *.o 6 | *.lo 7 | .libs 8 | *.la 9 | 10 | build 11 | 12 | *.perspectivev3 13 | *.pbxuser 14 | *.perspective 15 | *.mode1v3 16 | *.mode2v3 17 | *.tm_build_errors 18 | *.xcodeproj/xcuserdata 19 | *.xcodeproj/project.xcworkspace 20 | !default.pbxuser 21 | !default.perspectivev3 22 | !default.mode1v3 23 | !default.mode2v3 24 | 25 | *~.nib 26 | *~.xib 27 | 28 | Documentation/html 29 | Documentation/docset 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011 Aron Cedercrantz. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without modification, 4 | are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, 7 | this list of conditions and the following disclaimer. 8 | 9 | 2. Redistributions in binary form must reproduce the above copyright notice, 10 | this list of conditions and the following disclaimer in the documentation 11 | and/or other materials provided with the distribution. 12 | 13 | THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 14 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 16 | SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 17 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 18 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 19 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 21 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 22 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | 24 | The views and conclusions contained in the software and documentation are those 25 | of the authors and should not be interpreted as representing official policies, 26 | either expressed or implied, of Aron Cedercrantz. 27 | -------------------------------------------------------------------------------- /ObjectToXPC.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 9CB8193014BE6B4D00A2D29C /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C509AEC149CA69E00C47839 /* SenTestingKit.framework */; }; 11 | 9CB8193114BE6B4D00A2D29C /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C509AAE149B956700C47839 /* Cocoa.framework */; }; 12 | 9CB8193414BE6B4D00A2D29C /* ObjectToXPC.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9CB8191E14BE6B4C00A2D29C /* ObjectToXPC.framework */; }; 13 | 9CB8194414BE6B8A00A2D29C /* UnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C509AF6149CA69E00C47839 /* UnitTests.m */; }; 14 | 9CB8194514BE6BD800A2D29C /* ObjectToXPC-Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 9C509AB6149B956700C47839 /* ObjectToXPC-Prefix.pch */; }; 15 | 9CB8194614BE6BD800A2D29C /* ObjectToXPC-Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C509AC8149B9EF200C47839 /* ObjectToXPC-Private.h */; }; 16 | 9CB8194714BE6BD800A2D29C /* NSArray+CDXPC.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C509AC3149B95D700C47839 /* NSArray+CDXPC.h */; settings = {ATTRIBUTES = (Public, ); }; }; 17 | 9CB8194814BE6BD800A2D29C /* NSArray+CDXPC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C509AC4149B95D700C47839 /* NSArray+CDXPC.m */; }; 18 | 9CB8194914BE6BD800A2D29C /* NSData+CDXPC.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C509ADA149C9C9400C47839 /* NSData+CDXPC.h */; settings = {ATTRIBUTES = (Public, ); }; }; 19 | 9CB8194A14BE6BD800A2D29C /* NSData+CDXPC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C509ADB149C9C9400C47839 /* NSData+CDXPC.m */; }; 20 | 9CB8194B14BE6BD800A2D29C /* NSDate+CDXPC.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C509AD6149C9C3800C47839 /* NSDate+CDXPC.h */; settings = {ATTRIBUTES = (Public, ); }; }; 21 | 9CB8194C14BE6BD800A2D29C /* NSDate+CDXPC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C509AD7149C9C3800C47839 /* NSDate+CDXPC.m */; }; 22 | 9CB8194D14BE6BD800A2D29C /* NSDictionary+CDXPC.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C509ACA149C8B9400C47839 /* NSDictionary+CDXPC.h */; settings = {ATTRIBUTES = (Public, ); }; }; 23 | 9CB8194E14BE6BD800A2D29C /* NSDictionary+CDXPC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C509ACB149C8B9400C47839 /* NSDictionary+CDXPC.m */; }; 24 | 9CB8194F14BE6BD800A2D29C /* NSNumber+CDXPC.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C509AD1149C986100C47839 /* NSNumber+CDXPC.h */; settings = {ATTRIBUTES = (Public, ); }; }; 25 | 9CB8195014BE6BD800A2D29C /* NSNumber+CDXPC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C509AD2149C986100C47839 /* NSNumber+CDXPC.m */; }; 26 | 9CB8195114BE6BD800A2D29C /* NSString+CDXPC.h in Headers */ = {isa = PBXBuildFile; fileRef = 9C509ADE149C9CBB00C47839 /* NSString+CDXPC.h */; settings = {ATTRIBUTES = (Public, ); }; }; 27 | 9CB8195214BE6BD800A2D29C /* NSString+CDXPC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9C509ADF149C9CBB00C47839 /* NSString+CDXPC.m */; }; 28 | 9CB8195514BE6C2400A2D29C /* ObjectToXPC.h in Headers */ = {isa = PBXBuildFile; fileRef = 9CB8195314BE6C2400A2D29C /* ObjectToXPC.h */; }; 29 | 9CB8195914BE6C9A00A2D29C /* NSNull+CDXPC.h in Headers */ = {isa = PBXBuildFile; fileRef = 9CB8195714BE6C9A00A2D29C /* NSNull+CDXPC.h */; settings = {ATTRIBUTES = (Public, ); }; }; 30 | 9CB8195A14BE6C9A00A2D29C /* NSNull+CDXPC.m in Sources */ = {isa = PBXBuildFile; fileRef = 9CB8195814BE6C9A00A2D29C /* NSNull+CDXPC.m */; }; 31 | 9CB8196214BE6EA300A2D29C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9C509AB3149B956700C47839 /* Foundation.framework */; }; 32 | 9CB8196714BE70C100A2D29C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9CB8196514BE70C100A2D29C /* InfoPlist.strings */; }; 33 | 9CB8196A14BE70D000A2D29C /* ObjectToXPC-OSX-Prefix.pch in Headers */ = {isa = PBXBuildFile; fileRef = 9CB8196914BE70D000A2D29C /* ObjectToXPC-OSX-Prefix.pch */; }; 34 | 9CB8196C14BE710B00A2D29C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 9C509AF2149CA69E00C47839 /* InfoPlist.strings */; }; 35 | /* End PBXBuildFile section */ 36 | 37 | /* Begin PBXContainerItemProxy section */ 38 | 9CB8193214BE6B4D00A2D29C /* PBXContainerItemProxy */ = { 39 | isa = PBXContainerItemProxy; 40 | containerPortal = 9C509AA2149B956700C47839 /* Project object */; 41 | proxyType = 1; 42 | remoteGlobalIDString = 9CB8191D14BE6B4C00A2D29C; 43 | remoteInfo = "ObjectToXPC-OSX"; 44 | }; 45 | /* End PBXContainerItemProxy section */ 46 | 47 | /* Begin PBXFileReference section */ 48 | 9C509AAE149B956700C47839 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; 49 | 9C509AB1149B956700C47839 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 50 | 9C509AB2149B956700C47839 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; }; 51 | 9C509AB3149B956700C47839 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 52 | 9C509AB6149B956700C47839 /* ObjectToXPC-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "ObjectToXPC-Prefix.pch"; sourceTree = ""; }; 53 | 9C509AC3149B95D700C47839 /* NSArray+CDXPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+CDXPC.h"; sourceTree = ""; }; 54 | 9C509AC4149B95D700C47839 /* NSArray+CDXPC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSArray+CDXPC.m"; sourceTree = ""; }; 55 | 9C509AC8149B9EF200C47839 /* ObjectToXPC-Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ObjectToXPC-Private.h"; sourceTree = ""; }; 56 | 9C509ACA149C8B9400C47839 /* NSDictionary+CDXPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDictionary+CDXPC.h"; sourceTree = ""; }; 57 | 9C509ACB149C8B9400C47839 /* NSDictionary+CDXPC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDictionary+CDXPC.m"; sourceTree = ""; }; 58 | 9C509AD1149C986100C47839 /* NSNumber+CDXPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNumber+CDXPC.h"; sourceTree = ""; }; 59 | 9C509AD2149C986100C47839 /* NSNumber+CDXPC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNumber+CDXPC.m"; sourceTree = ""; }; 60 | 9C509AD6149C9C3800C47839 /* NSDate+CDXPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+CDXPC.h"; sourceTree = ""; }; 61 | 9C509AD7149C9C3800C47839 /* NSDate+CDXPC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSDate+CDXPC.m"; sourceTree = ""; }; 62 | 9C509ADA149C9C9400C47839 /* NSData+CDXPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+CDXPC.h"; sourceTree = ""; }; 63 | 9C509ADB149C9C9400C47839 /* NSData+CDXPC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+CDXPC.m"; sourceTree = ""; }; 64 | 9C509ADE149C9CBB00C47839 /* NSString+CDXPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+CDXPC.h"; sourceTree = ""; }; 65 | 9C509ADF149C9CBB00C47839 /* NSString+CDXPC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+CDXPC.m"; sourceTree = ""; }; 66 | 9C509AEC149CA69E00C47839 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; 67 | 9C509AF3149CA69E00C47839 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 68 | 9C509AF5149CA69E00C47839 /* UnitTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UnitTests.h; sourceTree = ""; }; 69 | 9C509AF6149CA69E00C47839 /* UnitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UnitTests.m; sourceTree = ""; }; 70 | 9CB8191E14BE6B4C00A2D29C /* ObjectToXPC.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ObjectToXPC.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 71 | 9CB8192F14BE6B4D00A2D29C /* ObjectToXPC-Tests.octest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "ObjectToXPC-Tests.octest"; sourceTree = BUILT_PRODUCTS_DIR; }; 72 | 9CB8195314BE6C2400A2D29C /* ObjectToXPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjectToXPC.h; sourceTree = ""; }; 73 | 9CB8195714BE6C9A00A2D29C /* NSNull+CDXPC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSNull+CDXPC.h"; sourceTree = ""; }; 74 | 9CB8195814BE6C9A00A2D29C /* NSNull+CDXPC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSNull+CDXPC.m"; sourceTree = ""; }; 75 | 9CB8195B14BE6D0A00A2D29C /* ObjectToXPC-Tests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "ObjectToXPC-Tests-Info.plist"; sourceTree = ""; }; 76 | 9CB8196514BE70C100A2D29C /* InfoPlist.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = InfoPlist.strings; path = ObjectToXPC/InfoPlist.strings; sourceTree = SOURCE_ROOT; }; 77 | 9CB8196614BE70C100A2D29C /* ObjectToXPC-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "ObjectToXPC-Info.plist"; path = "ObjectToXPC/ObjectToXPC-Info.plist"; sourceTree = SOURCE_ROOT; }; 78 | 9CB8196914BE70D000A2D29C /* ObjectToXPC-OSX-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "ObjectToXPC-OSX-Prefix.pch"; path = "ObjectToXPC/ObjectToXPC-OSX-Prefix.pch"; sourceTree = SOURCE_ROOT; }; 79 | /* End PBXFileReference section */ 80 | 81 | /* Begin PBXFrameworksBuildPhase section */ 82 | 9CB8191A14BE6B4C00A2D29C /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | 9CB8196214BE6EA300A2D29C /* Foundation.framework in Frameworks */, 87 | ); 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | 9CB8192B14BE6B4D00A2D29C /* Frameworks */ = { 91 | isa = PBXFrameworksBuildPhase; 92 | buildActionMask = 2147483647; 93 | files = ( 94 | 9CB8193014BE6B4D00A2D29C /* SenTestingKit.framework in Frameworks */, 95 | 9CB8193114BE6B4D00A2D29C /* Cocoa.framework in Frameworks */, 96 | 9CB8193414BE6B4D00A2D29C /* ObjectToXPC.framework in Frameworks */, 97 | ); 98 | runOnlyForDeploymentPostprocessing = 0; 99 | }; 100 | /* End PBXFrameworksBuildPhase section */ 101 | 102 | /* Begin PBXGroup section */ 103 | 9C509AA0149B956700C47839 = { 104 | isa = PBXGroup; 105 | children = ( 106 | 9C509B10149CF84800C47839 /* ObjectToXPC */, 107 | 9C509AEF149CA69E00C47839 /* UnitTests */, 108 | 9C509AAD149B956700C47839 /* Frameworks */, 109 | 9C509AAC149B956700C47839 /* Products */, 110 | ); 111 | sourceTree = ""; 112 | }; 113 | 9C509AAC149B956700C47839 /* Products */ = { 114 | isa = PBXGroup; 115 | children = ( 116 | 9CB8191E14BE6B4C00A2D29C /* ObjectToXPC.framework */, 117 | 9CB8192F14BE6B4D00A2D29C /* ObjectToXPC-Tests.octest */, 118 | ); 119 | name = Products; 120 | sourceTree = ""; 121 | }; 122 | 9C509AAD149B956700C47839 /* Frameworks */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 9C509AAE149B956700C47839 /* Cocoa.framework */, 126 | 9C509AEC149CA69E00C47839 /* SenTestingKit.framework */, 127 | 9C509AB0149B956700C47839 /* Other Frameworks */, 128 | ); 129 | name = Frameworks; 130 | sourceTree = ""; 131 | }; 132 | 9C509AB0149B956700C47839 /* Other Frameworks */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 9C509AB1149B956700C47839 /* AppKit.framework */, 136 | 9C509AB2149B956700C47839 /* CoreData.framework */, 137 | 9C509AB3149B956700C47839 /* Foundation.framework */, 138 | ); 139 | name = "Other Frameworks"; 140 | sourceTree = ""; 141 | }; 142 | 9C509AEF149CA69E00C47839 /* UnitTests */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 9C509AF5149CA69E00C47839 /* UnitTests.h */, 146 | 9C509AF6149CA69E00C47839 /* UnitTests.m */, 147 | 9C509AF0149CA69E00C47839 /* Supporting Files */, 148 | ); 149 | path = UnitTests; 150 | sourceTree = ""; 151 | }; 152 | 9C509AF0149CA69E00C47839 /* Supporting Files */ = { 153 | isa = PBXGroup; 154 | children = ( 155 | 9CB8195B14BE6D0A00A2D29C /* ObjectToXPC-Tests-Info.plist */, 156 | 9C509AF2149CA69E00C47839 /* InfoPlist.strings */, 157 | ); 158 | name = "Supporting Files"; 159 | sourceTree = ""; 160 | }; 161 | 9C509B10149CF84800C47839 /* ObjectToXPC */ = { 162 | isa = PBXGroup; 163 | children = ( 164 | 9CB8195314BE6C2400A2D29C /* ObjectToXPC.h */, 165 | 9C509AB6149B956700C47839 /* ObjectToXPC-Prefix.pch */, 166 | 9C509AC8149B9EF200C47839 /* ObjectToXPC-Private.h */, 167 | 9C509AC3149B95D700C47839 /* NSArray+CDXPC.h */, 168 | 9C509AC4149B95D700C47839 /* NSArray+CDXPC.m */, 169 | 9C509ADA149C9C9400C47839 /* NSData+CDXPC.h */, 170 | 9C509ADB149C9C9400C47839 /* NSData+CDXPC.m */, 171 | 9C509AD6149C9C3800C47839 /* NSDate+CDXPC.h */, 172 | 9C509AD7149C9C3800C47839 /* NSDate+CDXPC.m */, 173 | 9C509ACA149C8B9400C47839 /* NSDictionary+CDXPC.h */, 174 | 9C509ACB149C8B9400C47839 /* NSDictionary+CDXPC.m */, 175 | 9C509AD1149C986100C47839 /* NSNumber+CDXPC.h */, 176 | 9C509AD2149C986100C47839 /* NSNumber+CDXPC.m */, 177 | 9C509ADE149C9CBB00C47839 /* NSString+CDXPC.h */, 178 | 9C509ADF149C9CBB00C47839 /* NSString+CDXPC.m */, 179 | 9CB8195714BE6C9A00A2D29C /* NSNull+CDXPC.h */, 180 | 9CB8195814BE6C9A00A2D29C /* NSNull+CDXPC.m */, 181 | 9CB8192114BE6B4D00A2D29C /* Supporting Files */, 182 | ); 183 | path = ObjectToXPC; 184 | sourceTree = ""; 185 | }; 186 | 9CB8192114BE6B4D00A2D29C /* Supporting Files */ = { 187 | isa = PBXGroup; 188 | children = ( 189 | 9CB8196914BE70D000A2D29C /* ObjectToXPC-OSX-Prefix.pch */, 190 | 9CB8196514BE70C100A2D29C /* InfoPlist.strings */, 191 | 9CB8196614BE70C100A2D29C /* ObjectToXPC-Info.plist */, 192 | ); 193 | name = "Supporting Files"; 194 | path = "ObjectToXPC-OSX"; 195 | sourceTree = SOURCE_ROOT; 196 | }; 197 | /* End PBXGroup section */ 198 | 199 | /* Begin PBXHeadersBuildPhase section */ 200 | 9CB8191B14BE6B4C00A2D29C /* Headers */ = { 201 | isa = PBXHeadersBuildPhase; 202 | buildActionMask = 2147483647; 203 | files = ( 204 | 9CB8194514BE6BD800A2D29C /* ObjectToXPC-Prefix.pch in Headers */, 205 | 9CB8194614BE6BD800A2D29C /* ObjectToXPC-Private.h in Headers */, 206 | 9CB8194714BE6BD800A2D29C /* NSArray+CDXPC.h in Headers */, 207 | 9CB8194914BE6BD800A2D29C /* NSData+CDXPC.h in Headers */, 208 | 9CB8194B14BE6BD800A2D29C /* NSDate+CDXPC.h in Headers */, 209 | 9CB8194D14BE6BD800A2D29C /* NSDictionary+CDXPC.h in Headers */, 210 | 9CB8194F14BE6BD800A2D29C /* NSNumber+CDXPC.h in Headers */, 211 | 9CB8195114BE6BD800A2D29C /* NSString+CDXPC.h in Headers */, 212 | 9CB8195514BE6C2400A2D29C /* ObjectToXPC.h in Headers */, 213 | 9CB8195914BE6C9A00A2D29C /* NSNull+CDXPC.h in Headers */, 214 | 9CB8196A14BE70D000A2D29C /* ObjectToXPC-OSX-Prefix.pch in Headers */, 215 | ); 216 | runOnlyForDeploymentPostprocessing = 0; 217 | }; 218 | /* End PBXHeadersBuildPhase section */ 219 | 220 | /* Begin PBXNativeTarget section */ 221 | 9CB8191D14BE6B4C00A2D29C /* ObjectToXPC */ = { 222 | isa = PBXNativeTarget; 223 | buildConfigurationList = 9CB8193E14BE6B4D00A2D29C /* Build configuration list for PBXNativeTarget "ObjectToXPC" */; 224 | buildPhases = ( 225 | 9CB8191914BE6B4C00A2D29C /* Sources */, 226 | 9CB8191A14BE6B4C00A2D29C /* Frameworks */, 227 | 9CB8191B14BE6B4C00A2D29C /* Headers */, 228 | 9CB8191C14BE6B4C00A2D29C /* Resources */, 229 | ); 230 | buildRules = ( 231 | ); 232 | dependencies = ( 233 | ); 234 | name = ObjectToXPC; 235 | productName = "ObjectToXPC-OSX"; 236 | productReference = 9CB8191E14BE6B4C00A2D29C /* ObjectToXPC.framework */; 237 | productType = "com.apple.product-type.framework"; 238 | }; 239 | 9CB8192E14BE6B4D00A2D29C /* ObjectToXPC-Tests */ = { 240 | isa = PBXNativeTarget; 241 | buildConfigurationList = 9CB8194114BE6B4D00A2D29C /* Build configuration list for PBXNativeTarget "ObjectToXPC-Tests" */; 242 | buildPhases = ( 243 | 9CB8192A14BE6B4D00A2D29C /* Sources */, 244 | 9CB8192B14BE6B4D00A2D29C /* Frameworks */, 245 | 9CB8192C14BE6B4D00A2D29C /* Resources */, 246 | 9CB8192D14BE6B4D00A2D29C /* ShellScript */, 247 | ); 248 | buildRules = ( 249 | ); 250 | dependencies = ( 251 | 9CB8193314BE6B4D00A2D29C /* PBXTargetDependency */, 252 | ); 253 | name = "ObjectToXPC-Tests"; 254 | productName = "ObjectToXPC-OSXTests"; 255 | productReference = 9CB8192F14BE6B4D00A2D29C /* ObjectToXPC-Tests.octest */; 256 | productType = "com.apple.product-type.bundle"; 257 | }; 258 | /* End PBXNativeTarget section */ 259 | 260 | /* Begin PBXProject section */ 261 | 9C509AA2149B956700C47839 /* Project object */ = { 262 | isa = PBXProject; 263 | attributes = { 264 | LastUpgradeCheck = 0420; 265 | ORGANIZATIONNAME = "Aron Cedercrantz"; 266 | }; 267 | buildConfigurationList = 9C509AA5149B956700C47839 /* Build configuration list for PBXProject "ObjectToXPC" */; 268 | compatibilityVersion = "Xcode 3.2"; 269 | developmentRegion = English; 270 | hasScannedForEncodings = 0; 271 | knownRegions = ( 272 | en, 273 | ); 274 | mainGroup = 9C509AA0149B956700C47839; 275 | productRefGroup = 9C509AAC149B956700C47839 /* Products */; 276 | projectDirPath = ""; 277 | projectRoot = ""; 278 | targets = ( 279 | 9CB8191D14BE6B4C00A2D29C /* ObjectToXPC */, 280 | 9CB8192E14BE6B4D00A2D29C /* ObjectToXPC-Tests */, 281 | ); 282 | }; 283 | /* End PBXProject section */ 284 | 285 | /* Begin PBXResourcesBuildPhase section */ 286 | 9CB8191C14BE6B4C00A2D29C /* Resources */ = { 287 | isa = PBXResourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | 9CB8196714BE70C100A2D29C /* InfoPlist.strings in Resources */, 291 | ); 292 | runOnlyForDeploymentPostprocessing = 0; 293 | }; 294 | 9CB8192C14BE6B4D00A2D29C /* Resources */ = { 295 | isa = PBXResourcesBuildPhase; 296 | buildActionMask = 2147483647; 297 | files = ( 298 | 9CB8196C14BE710B00A2D29C /* InfoPlist.strings in Resources */, 299 | ); 300 | runOnlyForDeploymentPostprocessing = 0; 301 | }; 302 | /* End PBXResourcesBuildPhase section */ 303 | 304 | /* Begin PBXShellScriptBuildPhase section */ 305 | 9CB8192D14BE6B4D00A2D29C /* ShellScript */ = { 306 | isa = PBXShellScriptBuildPhase; 307 | buildActionMask = 2147483647; 308 | files = ( 309 | ); 310 | inputPaths = ( 311 | ); 312 | outputPaths = ( 313 | ); 314 | runOnlyForDeploymentPostprocessing = 0; 315 | shellPath = /bin/sh; 316 | shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; 317 | }; 318 | /* End PBXShellScriptBuildPhase section */ 319 | 320 | /* Begin PBXSourcesBuildPhase section */ 321 | 9CB8191914BE6B4C00A2D29C /* Sources */ = { 322 | isa = PBXSourcesBuildPhase; 323 | buildActionMask = 2147483647; 324 | files = ( 325 | 9CB8194814BE6BD800A2D29C /* NSArray+CDXPC.m in Sources */, 326 | 9CB8194A14BE6BD800A2D29C /* NSData+CDXPC.m in Sources */, 327 | 9CB8194C14BE6BD800A2D29C /* NSDate+CDXPC.m in Sources */, 328 | 9CB8194E14BE6BD800A2D29C /* NSDictionary+CDXPC.m in Sources */, 329 | 9CB8195014BE6BD800A2D29C /* NSNumber+CDXPC.m in Sources */, 330 | 9CB8195214BE6BD800A2D29C /* NSString+CDXPC.m in Sources */, 331 | 9CB8195A14BE6C9A00A2D29C /* NSNull+CDXPC.m in Sources */, 332 | ); 333 | runOnlyForDeploymentPostprocessing = 0; 334 | }; 335 | 9CB8192A14BE6B4D00A2D29C /* Sources */ = { 336 | isa = PBXSourcesBuildPhase; 337 | buildActionMask = 2147483647; 338 | files = ( 339 | 9CB8194414BE6B8A00A2D29C /* UnitTests.m in Sources */, 340 | ); 341 | runOnlyForDeploymentPostprocessing = 0; 342 | }; 343 | /* End PBXSourcesBuildPhase section */ 344 | 345 | /* Begin PBXTargetDependency section */ 346 | 9CB8193314BE6B4D00A2D29C /* PBXTargetDependency */ = { 347 | isa = PBXTargetDependency; 348 | target = 9CB8191D14BE6B4C00A2D29C /* ObjectToXPC */; 349 | targetProxy = 9CB8193214BE6B4D00A2D29C /* PBXContainerItemProxy */; 350 | }; 351 | /* End PBXTargetDependency section */ 352 | 353 | /* Begin PBXVariantGroup section */ 354 | 9C509AF2149CA69E00C47839 /* InfoPlist.strings */ = { 355 | isa = PBXVariantGroup; 356 | children = ( 357 | 9C509AF3149CA69E00C47839 /* en */, 358 | ); 359 | name = InfoPlist.strings; 360 | sourceTree = ""; 361 | }; 362 | /* End PBXVariantGroup section */ 363 | 364 | /* Begin XCBuildConfiguration section */ 365 | 9C509ABA149B956700C47839 /* Debug */ = { 366 | isa = XCBuildConfiguration; 367 | buildSettings = { 368 | ALWAYS_SEARCH_USER_PATHS = NO; 369 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 370 | CLANG_ENABLE_OBJC_ARC = YES; 371 | COPY_PHASE_STRIP = NO; 372 | GCC_C_LANGUAGE_STANDARD = gnu99; 373 | GCC_DYNAMIC_NO_PIC = NO; 374 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 375 | GCC_OPTIMIZATION_LEVEL = 0; 376 | GCC_PREPROCESSOR_DEFINITIONS = ( 377 | "DEBUG=1", 378 | "$(inherited)", 379 | ); 380 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 381 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 382 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 383 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 384 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 385 | GCC_WARN_UNUSED_VARIABLE = YES; 386 | MACOSX_DEPLOYMENT_TARGET = 10.7; 387 | ONLY_ACTIVE_ARCH = YES; 388 | RUN_CLANG_STATIC_ANALYZER = YES; 389 | SDKROOT = macosx; 390 | }; 391 | name = Debug; 392 | }; 393 | 9C509ABB149B956700C47839 /* Release */ = { 394 | isa = XCBuildConfiguration; 395 | buildSettings = { 396 | ALWAYS_SEARCH_USER_PATHS = NO; 397 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 398 | CLANG_ENABLE_OBJC_ARC = YES; 399 | COPY_PHASE_STRIP = YES; 400 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 401 | GCC_C_LANGUAGE_STANDARD = gnu99; 402 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 403 | GCC_VERSION = com.apple.compilers.llvm.clang.1_0; 404 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 405 | GCC_WARN_ABOUT_MISSING_PROTOTYPES = YES; 406 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 407 | GCC_WARN_UNUSED_VARIABLE = YES; 408 | MACOSX_DEPLOYMENT_TARGET = 10.7; 409 | RUN_CLANG_STATIC_ANALYZER = YES; 410 | SDKROOT = macosx; 411 | }; 412 | name = Release; 413 | }; 414 | 9CB8193F14BE6B4D00A2D29C /* Debug */ = { 415 | isa = XCBuildConfiguration; 416 | buildSettings = { 417 | DYLIB_COMPATIBILITY_VERSION = 1; 418 | DYLIB_CURRENT_VERSION = 1; 419 | FRAMEWORK_VERSION = A; 420 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 421 | GCC_PREFIX_HEADER = "ObjectToXPC/ObjectToXPC-Prefix.pch"; 422 | INFOPLIST_FILE = "ObjectToXPC/ObjectToXPC-Info.plist"; 423 | PRODUCT_NAME = "$(TARGET_NAME)"; 424 | WRAPPER_EXTENSION = framework; 425 | }; 426 | name = Debug; 427 | }; 428 | 9CB8194014BE6B4D00A2D29C /* Release */ = { 429 | isa = XCBuildConfiguration; 430 | buildSettings = { 431 | DYLIB_COMPATIBILITY_VERSION = 1; 432 | DYLIB_CURRENT_VERSION = 1; 433 | FRAMEWORK_VERSION = A; 434 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 435 | GCC_PREFIX_HEADER = "ObjectToXPC/ObjectToXPC-Prefix.pch"; 436 | INFOPLIST_FILE = "ObjectToXPC/ObjectToXPC-Info.plist"; 437 | PRODUCT_NAME = "$(TARGET_NAME)"; 438 | WRAPPER_EXTENSION = framework; 439 | }; 440 | name = Release; 441 | }; 442 | 9CB8194214BE6B4D00A2D29C /* Debug */ = { 443 | isa = XCBuildConfiguration; 444 | buildSettings = { 445 | FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; 446 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 447 | GCC_PREFIX_HEADER = "ObjectToXPC/ObjectToXPC-Prefix.pch"; 448 | INFOPLIST_FILE = "UnitTests/ObjectToXPC-Tests-Info.plist"; 449 | PRODUCT_NAME = "$(TARGET_NAME)"; 450 | WRAPPER_EXTENSION = octest; 451 | }; 452 | name = Debug; 453 | }; 454 | 9CB8194314BE6B4D00A2D29C /* Release */ = { 455 | isa = XCBuildConfiguration; 456 | buildSettings = { 457 | FRAMEWORK_SEARCH_PATHS = "$(DEVELOPER_LIBRARY_DIR)/Frameworks"; 458 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 459 | GCC_PREFIX_HEADER = "ObjectToXPC/ObjectToXPC-Prefix.pch"; 460 | INFOPLIST_FILE = "UnitTests/ObjectToXPC-Tests-Info.plist"; 461 | PRODUCT_NAME = "$(TARGET_NAME)"; 462 | WRAPPER_EXTENSION = octest; 463 | }; 464 | name = Release; 465 | }; 466 | /* End XCBuildConfiguration section */ 467 | 468 | /* Begin XCConfigurationList section */ 469 | 9C509AA5149B956700C47839 /* Build configuration list for PBXProject "ObjectToXPC" */ = { 470 | isa = XCConfigurationList; 471 | buildConfigurations = ( 472 | 9C509ABA149B956700C47839 /* Debug */, 473 | 9C509ABB149B956700C47839 /* Release */, 474 | ); 475 | defaultConfigurationIsVisible = 0; 476 | defaultConfigurationName = Release; 477 | }; 478 | 9CB8193E14BE6B4D00A2D29C /* Build configuration list for PBXNativeTarget "ObjectToXPC" */ = { 479 | isa = XCConfigurationList; 480 | buildConfigurations = ( 481 | 9CB8193F14BE6B4D00A2D29C /* Debug */, 482 | 9CB8194014BE6B4D00A2D29C /* Release */, 483 | ); 484 | defaultConfigurationIsVisible = 0; 485 | defaultConfigurationName = Release; 486 | }; 487 | 9CB8194114BE6B4D00A2D29C /* Build configuration list for PBXNativeTarget "ObjectToXPC-Tests" */ = { 488 | isa = XCConfigurationList; 489 | buildConfigurations = ( 490 | 9CB8194214BE6B4D00A2D29C /* Debug */, 491 | 9CB8194314BE6B4D00A2D29C /* Release */, 492 | ); 493 | defaultConfigurationIsVisible = 0; 494 | defaultConfigurationName = Release; 495 | }; 496 | /* End XCConfigurationList section */ 497 | }; 498 | rootObject = 9C509AA2149B956700C47839 /* Project object */; 499 | } 500 | -------------------------------------------------------------------------------- /ObjectToXPC/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /ObjectToXPC/NSArray+CDXPC.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import 33 | #import 34 | 35 | @interface NSArray (CDXPC) 36 | 37 | + (id)arrayWithXPCObject:(xpc_object_t)xpcObject; 38 | 39 | - (id)initWithXPCObject:(xpc_object_t)xpcObject; 40 | 41 | - (xpc_object_t)XPCObject; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /ObjectToXPC/NSArray+CDXPC.m: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | #import "NSArray+CDXPC.h" 32 | 33 | #import "NSData+CDXPC.h" 34 | #import "NSDate+CDXPC.h" 35 | #import "NSDictionary+CDXPC.h" 36 | #import "NSNumber+CDXPC.h" 37 | #import "NSString+CDXPC.h" 38 | 39 | #import "ObjectToXPC-Private.h" 40 | 41 | CD_FIX_CATEGORY_BUG(NSArray_CDXPC); 42 | @implementation NSArray (CDXPC) 43 | 44 | + (id)arrayWithXPCObject:(xpc_object_t)xpcObject 45 | { 46 | return [[[self class] alloc] initWithXPCObject:xpcObject]; 47 | } 48 | 49 | - (id)initWithXPCObject:(xpc_object_t)xpcObject 50 | { 51 | NSAssert(xpc_get_type(xpcObject) == XPC_TYPE_ARRAY, @"xpcObject must be of type XPC_TYPE_ARRAY."); 52 | 53 | NSUInteger capacity = xpc_array_get_count(xpcObject); 54 | NSMutableArray *newSelf = [[NSMutableArray alloc] initWithCapacity:capacity]; 55 | 56 | if (newSelf) { 57 | xpc_array_apply(xpcObject, ^_Bool(size_t index, xpc_object_t value) { 58 | xpc_type_t valueType = xpc_get_type(value); 59 | 60 | if (valueType == XPC_TYPE_ARRAY) { 61 | NSArray *array = [[NSArray alloc] initWithXPCObject:value]; 62 | [newSelf addObject:array]; 63 | } 64 | else if (valueType == XPC_TYPE_BOOL || 65 | valueType == XPC_TYPE_DOUBLE || 66 | valueType == XPC_TYPE_INT64 || 67 | valueType == XPC_TYPE_UINT64) { 68 | NSNumber *boolNumber = [[NSNumber alloc] initWithXPCObject:value]; 69 | [newSelf addObject:boolNumber]; 70 | } 71 | else if (valueType == XPC_TYPE_DATA) { 72 | NSData *data = [[NSData alloc] initWithXPCObject:value]; 73 | [newSelf addObject:data]; 74 | } 75 | else if (valueType == XPC_TYPE_DATE) { 76 | NSDate *date = [[NSDate alloc] initWithXPCObject:value]; 77 | [newSelf addObject:date]; 78 | } 79 | else if (valueType == XPC_TYPE_DICTIONARY) { 80 | NSDictionary *dictionary = [[NSDictionary alloc] initWithXPCObject:value]; 81 | [newSelf addObject:dictionary]; 82 | } 83 | else if (valueType == XPC_TYPE_NULL) { 84 | [newSelf addObject:[NSNull null]]; 85 | } 86 | else if (valueType == XPC_TYPE_STRING) { 87 | NSString *string = [[NSString alloc] initWithXPCObject:value]; 88 | [newSelf addObject:string]; 89 | } 90 | else { 91 | char *valueDescription = xpc_copy_description(value); 92 | NSString *assertionString = [[NSString alloc] initWithFormat:@"Unsupported XPC object '%s'.", valueDescription]; 93 | free(valueDescription); 94 | #if DEBUG 95 | NSAssert(NO, assertionString); 96 | #else 97 | NSLog(@"%@", assertionString); 98 | #endif 99 | } 100 | 101 | return true; 102 | }); 103 | } 104 | 105 | self = newSelf; 106 | return self; 107 | } 108 | 109 | - (xpc_object_t)XPCObject 110 | { 111 | xpc_object_t resXpcArray = xpc_array_create(NULL, 0); 112 | 113 | for (id obj in self) { 114 | if ([obj respondsToSelector:@selector(XPCObject)]) { 115 | xpc_object_t xpcObj = [obj XPCObject]; 116 | xpc_array_append_value(resXpcArray, xpcObj); 117 | xpc_release(xpcObj); 118 | } 119 | else if ([obj isKindOfClass:[NSNull class]]) { 120 | xpc_object_t nullObject = xpc_null_create(); 121 | xpc_array_set_value(resXpcArray, XPC_ARRAY_APPEND, nullObject); 122 | xpc_release(nullObject); 123 | } 124 | else { 125 | NSString *assertionString = [[NSString alloc] initWithFormat:@"Could not create XPC version of object '%@' of type %@.", obj, [obj class]]; 126 | #if DEBUG 127 | NSAssert(NO, assertionString); 128 | #else 129 | NSLog(@"%@", assertionString); 130 | #endif 131 | } 132 | } 133 | 134 | return resXpcArray; 135 | } 136 | 137 | @end 138 | -------------------------------------------------------------------------------- /ObjectToXPC/NSData+CDXPC.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | #import 32 | #import 33 | 34 | @interface NSData (CDXPC) 35 | 36 | + (id)dataWithXPCObject:(xpc_object_t)xpcObject; 37 | 38 | - (id)initWithXPCObject:(xpc_object_t)xpcObject; 39 | 40 | - (xpc_object_t)XPCObject; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /ObjectToXPC/NSData+CDXPC.m: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import "NSData+CDXPC.h" 33 | 34 | #import "ObjectToXPC-Private.h" 35 | 36 | CD_FIX_CATEGORY_BUG(NSData_CDXPC) 37 | @implementation NSData (CDXPC) 38 | 39 | + (id)dataWithXPCObject:(xpc_object_t)xpcObject 40 | { 41 | return [[[self class] alloc] initWithXPCObject:xpcObject]; 42 | } 43 | 44 | - (id)initWithXPCObject:(xpc_object_t)xpcObject 45 | { 46 | NSAssert(xpc_get_type(xpcObject) == XPC_TYPE_DATA, @"xpcObject must be of type XPC_TYPE_DATA"); 47 | 48 | NSUInteger length = xpc_data_get_length(xpcObject); 49 | const void *dataPtr = xpc_data_get_bytes_ptr(xpcObject); 50 | return [self initWithBytes:dataPtr length:length]; 51 | } 52 | 53 | - (xpc_object_t)XPCObject 54 | { 55 | const void *dataPtr = [self bytes]; 56 | NSUInteger length = [self length]; 57 | xpc_object_t resXpcData = xpc_data_create(dataPtr, length); 58 | 59 | return resXpcData; 60 | } 61 | 62 | @end 63 | -------------------------------------------------------------------------------- /ObjectToXPC/NSDate+CDXPC.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import 33 | #import 34 | 35 | @interface NSDate (CDXPC) 36 | 37 | + (id)dateWithXPCObject:(xpc_object_t)xpcObject; 38 | 39 | - (id)initWithXPCObject:(xpc_object_t)xpcObject; 40 | 41 | - (xpc_object_t)XPCObject; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /ObjectToXPC/NSDate+CDXPC.m: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import "NSDate+CDXPC.h" 33 | 34 | #import "ObjectToXPC-Private.h" 35 | 36 | CD_FIX_CATEGORY_BUG(NSDate_CDXPC) 37 | @implementation NSDate (CDXPC) 38 | 39 | + (id)dateWithXPCObject:(xpc_object_t)xpcObject 40 | { 41 | return [[[self class] alloc] initWithXPCObject:xpcObject]; 42 | } 43 | 44 | - (id)initWithXPCObject:(xpc_object_t)xpcObject 45 | { 46 | NSAssert(xpc_get_type(xpcObject) == XPC_TYPE_DATE, @"xpcObject must be of type XPC_TYPE_DATE"); 47 | 48 | int64_t unixTimestamp = xpc_date_get_value(xpcObject); 49 | return [self initWithTimeIntervalSince1970:unixTimestamp]; 50 | } 51 | 52 | - (xpc_object_t)XPCObject 53 | { 54 | xpc_object_t resXpcDate = xpc_date_create([self timeIntervalSince1970]); 55 | return resXpcDate; 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /ObjectToXPC/NSDictionary+CDXPC.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import 33 | #import 34 | 35 | @interface NSDictionary (CDXPC) 36 | 37 | + (id)dictionaryWithXPCObject:(xpc_object_t)xpcObject; 38 | 39 | - (id)initWithXPCObject:(xpc_object_t)xpcObject; 40 | 41 | - (xpc_object_t)XPCObject; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /ObjectToXPC/NSDictionary+CDXPC.m: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import "NSDictionary+CDXPC.h" 33 | 34 | #import "NSArray+CDXPC.h" 35 | #import "NSData+CDXPC.h" 36 | #import "NSDate+CDXPC.h" 37 | #import "NSNumber+CDXPC.h" 38 | #import "NSString+CDXPC.h" 39 | 40 | #import "ObjectToXPC-Private.h" 41 | 42 | CD_FIX_CATEGORY_BUG(NSDictionary_CDXPC) 43 | @implementation NSDictionary (CDXPC) 44 | 45 | + (id)dictionaryWithXPCObject:(xpc_object_t)xpcObject 46 | { 47 | return [[[self class] alloc] initWithXPCObject:xpcObject]; 48 | } 49 | 50 | - (id)initWithXPCObject:(xpc_object_t)xpcObject 51 | { 52 | NSAssert(xpc_get_type(xpcObject) == XPC_TYPE_DICTIONARY, @"xpcObject must be of type XPC_TYPE_DICTIONARY"); 53 | 54 | NSUInteger capacity = xpc_dictionary_get_count(xpcObject); 55 | NSMutableDictionary *newSelf = [[NSMutableDictionary alloc] initWithCapacity:capacity]; 56 | 57 | if (newSelf) { 58 | xpc_dictionary_apply(xpcObject, ^_Bool(const char *keyStr, xpc_object_t value) { 59 | NSString *key = [[NSString alloc] initWithUTF8String:keyStr]; 60 | xpc_type_t valueType = xpc_get_type(value); 61 | id object = nil; 62 | 63 | if (valueType == XPC_TYPE_ARRAY) { 64 | object = [[NSArray alloc] initWithXPCObject:value]; 65 | 66 | } 67 | else if (valueType == XPC_TYPE_BOOL || 68 | valueType == XPC_TYPE_DOUBLE || 69 | valueType == XPC_TYPE_INT64 || 70 | valueType == XPC_TYPE_UINT64) { 71 | object = [[NSNumber alloc] initWithXPCObject:value]; 72 | } 73 | else if (valueType == XPC_TYPE_DATA) { 74 | object = [[NSData alloc] initWithXPCObject:value]; 75 | } 76 | else if (valueType == XPC_TYPE_DATE) { 77 | object = [[NSDate alloc] initWithXPCObject:value]; 78 | } 79 | else if (valueType == XPC_TYPE_DICTIONARY) { 80 | object = [[NSDictionary alloc] initWithXPCObject:value]; 81 | } 82 | else if (valueType == XPC_TYPE_NULL) { 83 | object = [NSNull null]; 84 | } 85 | else if (valueType == XPC_TYPE_STRING) { 86 | object = [[NSString alloc] initWithXPCObject:value]; 87 | } 88 | else { 89 | char *valueDescription = xpc_copy_description(value); 90 | NSString *assertionString = [[NSString alloc] initWithFormat:@"Unsupported XPC object '%s'.", valueDescription]; 91 | free(valueDescription); 92 | #if DEBUG 93 | NSAssert(NO, assertionString); 94 | #else 95 | NSLog(@"%@", assertionString); 96 | #endif 97 | } 98 | 99 | if (object == nil) { 100 | object = [NSNull null]; 101 | } 102 | [newSelf setValue:object forKey:key]; 103 | 104 | return true; 105 | }); 106 | } 107 | 108 | self = newSelf; 109 | return self; 110 | } 111 | 112 | - (xpc_object_t)XPCObject 113 | { 114 | xpc_object_t resXpcDictionary = xpc_dictionary_create(NULL, NULL, 0); 115 | 116 | [self enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { 117 | xpc_object_t xpcObj = NULL; 118 | 119 | if ([obj respondsToSelector:@selector(XPCObject)]) { 120 | xpcObj = [obj XPCObject]; 121 | } 122 | else if ([obj isKindOfClass:[NSNull class]]) { 123 | xpcObj = xpc_null_create(); 124 | } 125 | else { 126 | NSString *assertionString = [[NSString alloc] initWithFormat:@"Could not create XPC version of object '%@' of type %@.", obj, [obj class]]; 127 | #if DEBUG 128 | NSAssert(NO, assertionString); 129 | #else 130 | NSLog(@"%@", assertionString); 131 | #endif 132 | } 133 | 134 | if (xpcObj != NULL) { 135 | // Make sure the key is a string! 136 | if (![key isKindOfClass:[NSString class]]) { 137 | key = [key description]; 138 | } 139 | const char *xpcKey = [key UTF8String]; 140 | 141 | xpc_dictionary_set_value(resXpcDictionary, xpcKey, xpcObj); 142 | 143 | xpc_release(xpcObj); 144 | } 145 | }]; 146 | 147 | return resXpcDictionary; 148 | } 149 | 150 | @end 151 | -------------------------------------------------------------------------------- /ObjectToXPC/NSNull+CDXPC.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import 33 | #import 34 | 35 | @interface NSNull (CDXPC) 36 | 37 | + (id)nullWithXPCObject:(xpc_object_t)xpcObject; 38 | 39 | - (id)initWithXPCObject:(xpc_object_t)xpcObject; 40 | 41 | - (xpc_object_t)XPCObject; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /ObjectToXPC/NSNull+CDXPC.m: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import "NSNull+CDXPC.h" 33 | 34 | #import "ObjectToXPC-Private.h" 35 | 36 | CD_FIX_CATEGORY_BUG(NSNull_CDXPC) 37 | @implementation NSNull (CDXPC) 38 | 39 | + (id)nullWithXPCObject:(xpc_object_t)xpcObject 40 | { 41 | return [self null]; 42 | } 43 | 44 | - (id)initWithXPCObject:(xpc_object_t)xpcObject 45 | { 46 | return [[self class] null]; 47 | } 48 | 49 | - (xpc_object_t)XPCObject 50 | { 51 | xpc_object_t resXpcNull = xpc_null_create(); 52 | return resXpcNull; 53 | } 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /ObjectToXPC/NSNumber+CDXPC.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import 33 | #import 34 | 35 | @interface NSNumber (CDXPC) 36 | 37 | + (id)numberWithXPCObject:(xpc_object_t)xpcObject; 38 | - (id)initWithXPCObject:(xpc_object_t)xpcObject; 39 | 40 | - (xpc_object_t)XPCObject; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /ObjectToXPC/NSNumber+CDXPC.m: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import "NSNumber+CDXPC.h" 33 | 34 | #import "ObjectToXPC-Private.h" 35 | 36 | CD_FIX_CATEGORY_BUG(NSNumber_CDXPC) 37 | @implementation NSNumber (CDXPC) 38 | 39 | + (id)numberWithXPCObject:(xpc_object_t)xpcObject 40 | { 41 | return [[[self class] alloc] initWithXPCObject:xpcObject]; 42 | } 43 | 44 | - (id)initWithXPCObject:(xpc_object_t)xpcObject 45 | { 46 | xpc_type_t objectType = xpc_get_type(xpcObject); 47 | NSAssert((objectType == XPC_TYPE_BOOL || 48 | objectType == XPC_TYPE_DOUBLE || 49 | objectType == XPC_TYPE_INT64 || 50 | objectType == XPC_TYPE_UINT64), 51 | @"xpcObject must be one of; bool, double, int64 or uint64."); 52 | 53 | 54 | NSNumber *newSelf = nil; 55 | if (objectType == XPC_TYPE_BOOL) { 56 | _Bool boolValue = xpc_bool_get_value(xpcObject); 57 | newSelf = [[NSNumber alloc] initWithBool:boolValue]; 58 | } 59 | else if (objectType == XPC_TYPE_DOUBLE) { 60 | double doubleValue = xpc_double_get_value(xpcObject); 61 | newSelf = [[NSNumber alloc] initWithDouble:doubleValue]; 62 | } 63 | else if (objectType == XPC_TYPE_INT64) { 64 | int64_t int64Value = xpc_int64_get_value(xpcObject); 65 | newSelf = [[NSNumber alloc] initWithLongLong:int64Value]; 66 | } 67 | else if (objectType == XPC_TYPE_UINT64) { 68 | uint64_t uint64Value = xpc_uint64_get_value(xpcObject); 69 | newSelf = [[NSNumber alloc] initWithUnsignedLongLong:uint64Value]; 70 | } 71 | 72 | self = newSelf; 73 | return self; 74 | } 75 | 76 | 77 | - (xpc_object_t)XPCObject 78 | { 79 | xpc_object_t resXpcNumber = NULL; 80 | 81 | // Bools 82 | if (strcmp([self objCType], "B") == 0) { 83 | resXpcNumber = xpc_bool_create(([self boolValue] == YES)); 84 | } 85 | // Integers (all stored as an int64_t) 86 | else if (strcmp([self objCType], "c") == 0 || 87 | strcmp([self objCType], "i") == 0 || 88 | strcmp([self objCType], "s") == 0 || 89 | strcmp([self objCType], "l") == 0 || 90 | strcmp([self objCType], "q") == 0) { 91 | 92 | resXpcNumber = xpc_int64_create([self longLongValue]); 93 | } 94 | // Unsigned integers (all stored as an uint64_t) 95 | else if (strcmp([self objCType], "C") == 0 || 96 | strcmp([self objCType], "I") == 0 || 97 | strcmp([self objCType], "S") == 0 || 98 | strcmp([self objCType], "L") == 0 || 99 | strcmp([self objCType], "Q") == 0) { 100 | 101 | resXpcNumber = xpc_uint64_create([self unsignedLongLongValue]); 102 | } 103 | // Floats and doubles (all stored as an double) 104 | else if (strcmp([self objCType], "f") == 0 || 105 | strcmp([self objCType], "d") == 0) { 106 | 107 | resXpcNumber = xpc_double_create([self doubleValue]); 108 | } 109 | 110 | return resXpcNumber; 111 | } 112 | 113 | @end 114 | -------------------------------------------------------------------------------- /ObjectToXPC/NSString+CDXPC.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import 33 | #import 34 | 35 | @interface NSString (CDXPC) 36 | 37 | + (id)stringWithXPCObject:(xpc_object_t)xpcObject; 38 | 39 | - (id)initWithXPCObject:(xpc_object_t)xpcObject; 40 | 41 | - (xpc_object_t)XPCObject; 42 | 43 | @end -------------------------------------------------------------------------------- /ObjectToXPC/NSString+CDXPC.m: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import "NSString+CDXPC.h" 33 | 34 | #import "ObjectToXPC-Private.h" 35 | 36 | CD_FIX_CATEGORY_BUG(NSString_CDXPC) 37 | @implementation NSString (CDXPC) 38 | 39 | + (id)stringWithXPCObject:(xpc_object_t)xpcObject 40 | { 41 | return [[[self class] alloc] initWithXPCObject:xpcObject]; 42 | } 43 | 44 | - (id)initWithXPCObject:(xpc_object_t)xpcObject 45 | { 46 | NSAssert(xpc_get_type(xpcObject) == XPC_TYPE_STRING, @"xpcObject must be of type XPC_TYPE_STRING"); 47 | 48 | const char *xpcString = xpc_string_get_string_ptr(xpcObject); 49 | return [self initWithUTF8String:xpcString]; 50 | } 51 | 52 | - (xpc_object_t)XPCObject 53 | { 54 | xpc_object_t resXpcString = xpc_string_create([self UTF8String]); 55 | return resXpcString; 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /ObjectToXPC/ObjectToXPC-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.cedercrantz.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | FMWK 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | NSHumanReadableCopyright 26 | Copyright © 2012 Icomera. All rights reserved. 27 | NSPrincipalClass 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /ObjectToXPC/ObjectToXPC-OSX-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'ObjectToXPC-OSX' target in the 'ObjectToXPC-OSX' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /ObjectToXPC/ObjectToXPC-Prefix.pch: -------------------------------------------------------------------------------- 1 | /// 2 | // ObjectToXPC 3 | // 4 | // Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without 7 | // modification, are permitted provided that the following conditions are met: 8 | // 9 | // 1. Redistributions of source code must retain the above copyright notice, 10 | // this list of conditions and the following disclaimer. 11 | // 12 | // 2. Redistributions in binary form must reproduce the above copyright notice, 13 | // this list of conditions and the following disclaimer in the documentation 14 | // and/or other materials provided with the distribution. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | // EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | // 27 | // The views and conclusions contained in the software and documentation are 28 | // those of the authors and should not be interpreted as representing official 29 | // policies, either expressed or implied, of Aron Cedercrantz. 30 | /// 31 | 32 | #ifdef __OBJC__ 33 | #import 34 | #endif 35 | -------------------------------------------------------------------------------- /ObjectToXPC/ObjectToXPC-Private.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #ifndef ObjectToXPC_CollectionToXPC_Private_h 33 | #define ObjectToXPC_CollectionToXPC_Private_h 34 | 35 | /** 36 | * Force a category to be loaded when an app starts up. 37 | * 38 | * Add this macro before each category implementation, so we don't have to use 39 | * -all_load or -force_load to load object files from static libraries that only contain 40 | * categories and no classes. 41 | * See http://developer.apple.com/library/mac/#qa/qa2006/qa1490.html for more info. 42 | * 43 | * Macro from the Numbis project at https://github.com/jverkoey/nimbus/. 44 | */ 45 | #define CD_FIX_CATEGORY_BUG(name) @interface CD_FIX_CATEGORY_BUG_##name @end \ 46 | @implementation CD_FIX_CATEGORY_BUG_##name @end 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /ObjectToXPC/ObjectToXPC.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import 33 | #import 34 | #import 35 | #import 36 | #import 37 | #import 38 | #import 39 | 40 | -------------------------------------------------------------------------------- /README.mdown: -------------------------------------------------------------------------------- 1 | # ObjectToXPC # 2 | A bunch of categories for converting a few types of Objective-C objects (defined in the [Foundation framework](http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/ObjC_classic/_index.html)) to and from [XPC](http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/CreatingXPCServices.html) objects. 3 | 4 | Also see the blog post about it "[Convert Between XPC Objects and Objective-C Objects](http://aron.cedercrantz.com/2011/12/17/convert-between-xpc-objects-and-objective-c/)." 5 | 6 | ## Supported objects ## 7 | ### Objective-C objects ### 8 | - `NSArray` (where the elements are one of the supported), 9 | - `NSData`, 10 | - `NSDate`, 11 | - `NSDictionary` (where the elements are one of the supported, keys must either be of the NSString class or define the `-description` method), 12 | - `NSNull` (only in collections), 13 | - `NSNumber`, 14 | - `NSString`. 15 | 16 | ### XPC object types ### 17 | - `XPC_TYPE_ARRAY` 18 | - `XPC_TYPE_BOOL` 19 | - `XPC_TYPE_DATA` (to and from `NSNumber`) 20 | - `XPC_TYPE_DATE` 21 | - `XPC_TYPE_DICTIONARY` 22 | - `XPC_TYPE_DOUBLE` (to and from `NSNumber`) 23 | - `XPC_TYPE_INT64` (to and from `NSNumber`) 24 | - `XPC_TYPE_UINT64` (to and from `NSNumber`) 25 | - `XPC_TYPE_NULL` 26 | - `XPC_TYPE_STRING` 27 | 28 | 29 | ## Requirements ## 30 | The project requires Mac OS X 10.7+ and Xcode 4.2 to build and Mac OS X 10.7+ to run as the XPC Services API was first introduced in OS X 10.7. Will not work on iOS as the XPC API is not available here. Furthermore, the project have been written for automatic reference counting (ARC). 31 | 32 | 33 | ## Usage ## 34 | Either include the source files directly (in which case you will also need the (`ObjectToXPC-Private.h` header file) or link with the library. 35 | 36 | 37 | ## License ## 38 | The project is licensed under the "Simplified BSD license" (2-clause), for the exact terms please see the [LICENSE file](https://github.com/rastersize/ObjectToXPC/blob/master/LICENSE). 39 | 40 | -------------------------------------------------------------------------------- /TODO.mdown: -------------------------------------------------------------------------------- 1 | # TODO # 2 | - Add API documentation. -------------------------------------------------------------------------------- /UnitTests/ObjectToXPC-Tests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.cedercrantz.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /UnitTests/UnitTests.h: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import 33 | 34 | @interface UnitTests : SenTestCase 35 | 36 | - (void)testArrayObject; 37 | - (void)testDataObject; 38 | - (void)testDateObject; 39 | - (void)testDictionaryObject; 40 | - (void)testNullObject; 41 | - (void)testNumberObject; 42 | - (void)testStringObject; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /UnitTests/UnitTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * ObjectToXPC 3 | * 4 | * Copyright 2011 Aron Cedercrantz. All rights reserved. 5 | * 6 | * Redistribution and use in source and binary forms, with or without 7 | * modification, are permitted provided that the following conditions are met: 8 | * 9 | * 1. Redistributions of source code must retain the above copyright notice, 10 | * this list of conditions and the following disclaimer. 11 | * 12 | * 2. Redistributions in binary form must reproduce the above copyright notice, 13 | * this list of conditions and the following disclaimer in the documentation 14 | * and/or other materials provided with the distribution. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY ARON CEDERCRANTZ ''AS IS'' AND ANY EXPRESS OR 17 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 | * EVENT SHALL ARON CEDERCRANTZ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 20 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | * 27 | * The views and conclusions contained in the software and documentation are 28 | * those of the authors and should not be interpreted as representing official 29 | * policies, either expressed or implied, of Aron Cedercrantz. 30 | */ 31 | 32 | #import "UnitTests.h" 33 | 34 | #import "NSArray+CDXPC.h" 35 | #import "NSData+CDXPC.h" 36 | #import "NSDate+CDXPC.h" 37 | #import "NSDictionary+CDXPC.h" 38 | #import "NSNumber+CDXPC.h" 39 | #import "NSString+CDXPC.h" 40 | #import "NSNull+CDXPC.h" 41 | 42 | @implementation UnitTests 43 | 44 | - (void)setUp 45 | { 46 | [super setUp]; 47 | 48 | // Set-up code here. 49 | } 50 | 51 | - (void)tearDown 52 | { 53 | // Tear-down code here. 54 | 55 | [super tearDown]; 56 | } 57 | 58 | - (void)testArrayObject 59 | { 60 | NSArray *array = [NSArray arrayWithObjects:@"foo", @"bar", nil]; 61 | NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:3600.0]; 62 | NSData *data = [@"Some data..." dataUsingEncoding:NSUTF8StringEncoding]; 63 | NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"anObject", @"aKey", nil]; 64 | NSNull *nullObj = [NSNull null]; 65 | 66 | NSNumber *numberBool = [NSNumber numberWithBool:YES]; 67 | NSNumber *numberDouble = [NSNumber numberWithDouble:123.456]; 68 | NSNumber *numberInt64 = [NSNumber numberWithLongLong:-123456]; 69 | NSNumber *numberUint64 = [NSNumber numberWithUnsignedLongLong:123456]; 70 | 71 | NSString *string = @"A nice and relatively long string."; 72 | 73 | NSArray *objc_array = [NSArray arrayWithObjects: 74 | array, 75 | date, 76 | data, 77 | dictionary, 78 | nullObj, 79 | numberBool, 80 | numberDouble, 81 | numberInt64, 82 | numberUint64, 83 | string, 84 | nil]; 85 | xpc_object_t xpc_arrayFromObjc = [objc_array XPCObject]; 86 | STAssertTrue(xpc_arrayFromObjc != NULL, @"XPCObject must NOT return NULL for a populated NSArray."); 87 | STAssertTrue(xpc_get_type(xpc_arrayFromObjc) == XPC_TYPE_ARRAY, @"Returned XPCObject must be of type XPC_TYPE_ARRAY."); 88 | 89 | 90 | NSArray *objc_arrayFromXpc = [NSArray arrayWithXPCObject:xpc_arrayFromObjc]; 91 | STAssertNotNil(objc_arrayFromXpc, @"Initiating from an XPC array object should NOT return NULL/nil."); 92 | STAssertFalse(objc_array == objc_arrayFromXpc, @"The objc_array pointer should NOT be equal to the objc_arrayFromXpc pointer."); 93 | STAssertEqualObjects(objc_array, objc_arrayFromXpc, @"objc_array must be equal to objc_arrayFromXpc content wise."); 94 | } 95 | 96 | - (void)testDataObject 97 | { 98 | NSData *objc_data = [@"test data string" dataUsingEncoding:NSUTF8StringEncoding]; 99 | xpc_object_t xpc_dataFromObjc = [objc_data XPCObject]; 100 | STAssertTrue(xpc_dataFromObjc != NULL, @"XPCObject must NOT return NULL for a NSData object with data."); 101 | STAssertTrue(xpc_get_type(xpc_dataFromObjc) == XPC_TYPE_DATA, @"Returned XPCObject must be of type XPC_TYPE_DATA."); 102 | 103 | NSData *objc_dataFromXpc = [NSData dataWithXPCObject:xpc_dataFromObjc]; 104 | STAssertNotNil(objc_dataFromXpc, @"Initiating from an XPC data object should NOT return NULL/nil."); 105 | STAssertFalse(objc_data == objc_dataFromXpc, @"The objc_data pointer should NOT be equal to the objc_dataFromXpc pointer."); 106 | STAssertEqualObjects(objc_data, objc_dataFromXpc, @"objc_data must be equal to objc_dataFromXpc content wise."); 107 | } 108 | 109 | - (void)testDateObject 110 | { 111 | NSDate *objc_date = [NSDate dateWithTimeIntervalSince1970:3600]; 112 | xpc_object_t xpc_dateFromObjc = [objc_date XPCObject]; 113 | STAssertTrue(xpc_dateFromObjc != NULL, @"XPCObject must NOT return NULL."); 114 | STAssertTrue(xpc_get_type(xpc_dateFromObjc) == XPC_TYPE_DATE, @"Returned XPCObject must be of type XPC_TYPE_DATE."); 115 | 116 | NSDate *objc_dateFromXpc = [NSDate dateWithXPCObject:xpc_dateFromObjc]; 117 | STAssertNotNil(objc_dateFromXpc, @"Initiating from an XPC date object should NOT return NULL/nil."); 118 | STAssertEqualObjects(objc_date, objc_dateFromXpc, @"objc_date must be equal to objc_dateFromXpc content wise."); 119 | } 120 | 121 | - (void)testDictionaryObject 122 | { 123 | NSString *arrayKey = @"array"; 124 | NSArray *array = [NSArray arrayWithObjects:@"foo", @"bar", nil]; 125 | NSString *dateKey = @"date"; 126 | NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate:3600.0]; 127 | NSString *dataKey = @"data"; 128 | NSData *data = [@"Some data..." dataUsingEncoding:NSUTF8StringEncoding]; 129 | NSString *dictionaryKey = @"dict"; 130 | NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"anObject", @"aKey", nil]; 131 | NSString *nullKey = @"null"; 132 | NSNull *nullObj = [NSNull null]; 133 | 134 | NSString *boolKey = @"bool"; 135 | NSNumber *numberBool = [NSNumber numberWithBool:YES]; 136 | NSString *doubleKey = @"double"; 137 | NSNumber *numberDouble = [NSNumber numberWithDouble:123.456]; 138 | NSString *int64Key = @"int64"; 139 | NSNumber *numberInt64 = [NSNumber numberWithLongLong:-123456]; 140 | NSString *uint64Key = @"uint64"; 141 | NSNumber *numberUint64 = [NSNumber numberWithUnsignedLongLong:123456]; 142 | 143 | NSString *stringKey = @"string"; 144 | NSString *string = @"A nice and relatively long string."; 145 | 146 | NSDictionary *objc_dict = [NSDictionary dictionaryWithObjectsAndKeys: 147 | array, arrayKey, 148 | date, dateKey, 149 | data, dataKey, 150 | dictionary, dictionaryKey, 151 | nullObj, nullKey, 152 | numberBool, boolKey, 153 | numberDouble, doubleKey, 154 | numberInt64, int64Key, 155 | numberUint64, uint64Key, 156 | string, stringKey, 157 | nil]; 158 | 159 | xpc_object_t xpc_dictFromObjc = [objc_dict XPCObject]; 160 | STAssertTrue(xpc_dictFromObjc != NULL, @"XPCObject must NOT return NULL for a populated NSDictionary."); 161 | STAssertTrue(xpc_get_type(xpc_dictFromObjc) == XPC_TYPE_DICTIONARY, @"Returned XPCObject must be of type XPC_TYPE_DICTIONARY."); 162 | 163 | 164 | NSDictionary *objc_dictFromXpc = [NSDictionary dictionaryWithXPCObject:xpc_dictFromObjc]; 165 | STAssertNotNil(objc_dictFromXpc, @"Initiating from an XPC dictionary object should NOT return NULL/nil."); 166 | STAssertFalse(objc_dict == objc_dictFromXpc, @"The objc_dict pointer should NOT be equal to the objc_dictFromXpc pointer."); 167 | STAssertEqualObjects(objc_dict, objc_dictFromXpc, @"objc_dict must be equal to objc_dictFromXpc content wise."); 168 | } 169 | 170 | - (void)testNumberObject 171 | { 172 | BOOL primitive_bool_yes = YES; 173 | BOOL primitive_bool_no = NO; 174 | int64_t primitive_int64 = INT64_MIN + 1;//-549755813888; // 2^39 = (2^40)/2 175 | uint64_t primitive_uint64 = UINT64_MAX - 1; //1099511627776; // 2^40 176 | double primitive_double = 1.234567890; 177 | 178 | NSNumber *objc_number_bool_yes = [NSNumber numberWithBool:primitive_bool_yes]; 179 | NSNumber *objc_number_bool_no = [NSNumber numberWithBool:primitive_bool_no]; 180 | NSNumber *objc_number_int64 = [NSNumber numberWithLongLong:primitive_int64]; 181 | NSNumber *objc_number_uint64 = [NSNumber numberWithUnsignedLongLong:primitive_uint64]; 182 | NSNumber *objc_number_double = [NSNumber numberWithDouble:primitive_double]; 183 | 184 | xpc_object_t xpc_number_bool_yes = [objc_number_bool_yes XPCObject]; 185 | xpc_object_t xpc_number_bool_no = [objc_number_bool_no XPCObject]; 186 | xpc_object_t xpc_number_int64 = [objc_number_int64 XPCObject]; 187 | xpc_object_t xpc_number_uint64 = [objc_number_uint64 XPCObject]; 188 | xpc_object_t xpc_number_double = [objc_number_double XPCObject]; 189 | 190 | // XPC objects MUST NOT be NULL/nil 191 | STAssertTrue(xpc_number_bool_yes != NULL, @"XPCObject must NOT return NULL for a boolean (true) number."); 192 | STAssertTrue(xpc_number_bool_no != NULL, @"XPCObject must NOT return NULL for a boolean (false) number."); 193 | STAssertTrue(xpc_number_int64 != NULL, @"XPCObject must NOT return NULL for a int64 number."); 194 | STAssertTrue(xpc_number_uint64 != NULL, @"XPCObject must NOT return NULL for a uint64 number."); 195 | STAssertTrue(xpc_number_double != NULL, @"XPCObject must NOT return NULL for a double number."); 196 | 197 | // XPC objcets MUST be of correct type 198 | // It can not be guaranteed that a BOOL will be stored as a BOOL inside a 199 | // NSNumber (NSNumber implementation detail) it can (and is) for instance be 200 | // stored as an char. 201 | STAssertTrue(xpc_get_type(xpc_number_bool_yes) == XPC_TYPE_BOOL || 202 | xpc_get_type(xpc_number_bool_yes) == XPC_TYPE_INT64, @"Returned XPCObject must be of type XPC_TYPE_BOOL for a boolean (true) number."); 203 | // It can not be guaranteed that a BOOL will be stored as a BOOL inside a 204 | // NSNumber (NSNumber implementation detail) it can (and is) for instance be 205 | // stored as an char. 206 | STAssertTrue(xpc_get_type(xpc_number_bool_no) == XPC_TYPE_BOOL || 207 | xpc_get_type(xpc_number_bool_no) == XPC_TYPE_INT64, @"Returned XPCObject must be of type XPC_TYPE_BOOL for a boolean (false) number."); 208 | STAssertTrue(xpc_get_type(xpc_number_int64) == XPC_TYPE_INT64, @"Returned XPCObject must be of type XPC_TYPE_INT64 for a int64 number."); 209 | STAssertTrue(xpc_get_type(xpc_number_uint64) == XPC_TYPE_UINT64, @"Returned XPCObject must be of type XPC_TYPE_UINT64 for a uint64 number."); 210 | STAssertTrue(xpc_get_type(xpc_number_double) == XPC_TYPE_DOUBLE, @"Returned XPCObject must be of type XPC_TYPE_DOUBLE for a double number."); 211 | 212 | 213 | NSNumber *objc_number_bool_yesFromXpc = [NSNumber numberWithXPCObject:xpc_number_bool_yes]; 214 | NSNumber *objc_number_bool_noFromXpc = [NSNumber numberWithXPCObject:xpc_number_bool_no]; 215 | NSNumber *objc_number_int64FromXpc = [NSNumber numberWithXPCObject:xpc_number_int64]; 216 | NSNumber *objc_number_uint64FromXpc = [NSNumber numberWithXPCObject:xpc_number_uint64]; 217 | NSNumber *objc_number_doubleFromXpc = [NSNumber numberWithXPCObject:xpc_number_double]; 218 | 219 | // NSNumber objects derived from XPC objects MUST NOT be NULL/nil 220 | STAssertNotNil(objc_number_bool_yesFromXpc, @"Initiating from an XPC boolean (true) object should not return NULL/nil."); 221 | STAssertNotNil(objc_number_bool_noFromXpc, @"Initiating from an XPC boolean (false) object should not return NULL/nil."); 222 | STAssertNotNil(objc_number_int64FromXpc, @"Initiating from an XPC int64 object should not return NULL/nil."); 223 | STAssertNotNil(objc_number_uint64FromXpc, @"Initiating from an XPC uint64 object should not return NULL/nil."); 224 | STAssertNotNil(objc_number_doubleFromXpc, @"Initiating from an XPC doulbe object should not return NULL/nil."); 225 | 226 | // NSNumber objects derived from XPC objects SHOULD be new instances 227 | STAssertFalse(objc_number_bool_yes == objc_number_bool_yesFromXpc, @"The objc_number_bool_yes pointer should NOT be equal to the objc_number_bool_yesFromXpc pointer."); 228 | STAssertFalse(objc_number_bool_no == objc_number_bool_noFromXpc, @"The objc_number_bool_no pointer should NOT be equal to the objc_number_bool_noFromXpc pointer."); 229 | STAssertFalse(objc_number_int64 == objc_number_int64FromXpc, @"The objc_number_int64 pointer should NOT be equal to the objc_number_int64FromXpc pointer."); 230 | STAssertFalse(objc_number_uint64 == objc_number_uint64FromXpc, @"The objc_number_uint64 pointer should NOT be equal to the objc_number_uint64FromXpc pointer."); 231 | STAssertFalse(objc_number_double == objc_number_doubleFromXpc, @"The objc_number_double pointer should NOT be equal to the objc_number_doubleFromXpc pointer."); 232 | 233 | // NSNumber objects derived from XPC objects MUST be equal to original 234 | // NSNumber objects 235 | STAssertEqualObjects(objc_number_bool_yes, objc_number_bool_yesFromXpc, @"objc_number_bool_yes must be equal to objc_number_bool_yesFromXpc content wise."); 236 | STAssertEqualObjects(objc_number_bool_no, objc_number_bool_noFromXpc, @"objc_number_bool_no must be equal to objc_number_bool_noFromXpc content wise."); 237 | STAssertEqualObjects(objc_number_int64, objc_number_int64FromXpc, @"objc_number_int64 must be equal to objc_number_int64FromXpc content wise."); 238 | STAssertEqualObjects(objc_number_uint64, objc_number_uint64FromXpc, @"objc_number_uint64 must be equal to objc_number_uint64FromXpc content wise."); 239 | STAssertEqualObjects(objc_number_double, objc_number_doubleFromXpc, @"objc_number_double must be equal to objc_number_doubleFromXpc content wise."); 240 | 241 | 242 | bool extracted_primitive_bool_yes = [objc_number_bool_yesFromXpc boolValue]; 243 | bool extracted_primitive_bool_no = [objc_number_bool_noFromXpc boolValue]; 244 | int64_t extracted_primitive_int64 = [objc_number_int64FromXpc longLongValue]; 245 | uint64_t extracted_primitive_uint64 = [objc_number_uint64FromXpc unsignedLongLongValue]; 246 | double extracted_primitive_double = [objc_number_doubleFromXpc doubleValue]; 247 | 248 | // The extracted primitive values of the derived NSNumber objcets should be 249 | // the same as the original primitives 250 | STAssertTrue(primitive_bool_yes == extracted_primitive_bool_yes, @"The original primitive 'primitive_bool_yes' should be equal to the extracted primitive 'extracted_primitive_bool_yes'."); 251 | STAssertTrue(primitive_bool_no == extracted_primitive_bool_no, @"The original primitive 'primitive_bool_no' should be equal to the extracted primitive 'extracted_primitive_bool_no'."); 252 | STAssertTrue(primitive_int64 == extracted_primitive_int64, @"The original primitive 'primitive_int64' should be equal to the extracted primitive 'extracted_primitive_int64'."); 253 | STAssertTrue(primitive_uint64 == extracted_primitive_uint64, @"The original primitive 'primitive_uint64' should be equal to the extracted primitive 'extracted_primitive_uint64'."); 254 | STAssertTrue(primitive_double == extracted_primitive_double, @"The original primitive 'primitive_double' should be equal to the extracted primitive 'extracted_primitive_double'."); 255 | } 256 | 257 | - (void)testStringObject 258 | { 259 | NSString *objc_string = @"A nice test string!"; 260 | xpc_object_t xpc_stringFromObjc = [objc_string XPCObject]; 261 | STAssertTrue(xpc_stringFromObjc != NULL, @"XPCObject must NOT return NULL."); 262 | STAssertTrue(xpc_get_type(xpc_stringFromObjc) == XPC_TYPE_STRING, @"Returned XPCObject must be of type XPC_TYPE_STRING."); 263 | 264 | NSString *objc_stringFromXpc = [NSString stringWithXPCObject:xpc_stringFromObjc]; 265 | STAssertNotNil(objc_stringFromXpc, @"Initiating from an XPC string object should NOT return NULL/nil."); 266 | STAssertEqualObjects(objc_string, objc_stringFromXpc, @"objc_string must be equal to objc_stringFromXpc content wise."); 267 | } 268 | 269 | - (void)testNullObject 270 | { 271 | NSNull *objc_null = [NSNull null]; 272 | xpc_object_t xpc_nullFromObjc = [objc_null XPCObject]; 273 | STAssertTrue(xpc_get_type(xpc_nullFromObjc) == XPC_TYPE_NULL, @"Returned XPCObject must be of type XPC_TYPE_NULL."); 274 | 275 | NSNull *objc_nullFromXpc = [NSNull nullWithXPCObject:xpc_nullFromObjc]; 276 | STAssertEqualObjects(objc_null, objc_nullFromXpc, @"objc_null must be equal to objc_nullFromXpc 'content' wise."); 277 | } 278 | 279 | 280 | @end 281 | -------------------------------------------------------------------------------- /UnitTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | --------------------------------------------------------------------------------