Skip to content

Commit e517361

Browse files
committed
[PlaygroundLogger] Implemented exception handling around potentially risky NSKeyedArchiver operations.
While most of our use of NSKeyedArchiver should be safe, encoding NSAttributedString, NSBezierPath, and UIBezierPath is potentially risky and may throw exceptions. As a result, we need to perform this encoding in Objective-C source files compiled with `-fobjc-arc-exceptions` so we can correctly handle the exception and propagate the encoding failure as an error.
1 parent 92b7e16 commit e517361

11 files changed

+241
-10
lines changed

PlaygroundLogger/PlaygroundLogger.xcodeproj/project.pbxproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@
8484
5EF581532041387C00AC14FE /* CustomPlaygroundDisplayConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EF581512041384700AC14FE /* CustomPlaygroundDisplayConvertibleTests.swift */; };
8585
5EF581542041387C00AC14FE /* CustomPlaygroundDisplayConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EF581512041384700AC14FE /* CustomPlaygroundDisplayConvertibleTests.swift */; };
8686
5EF581552041387C00AC14FE /* CustomPlaygroundDisplayConvertibleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EF581512041384700AC14FE /* CustomPlaygroundDisplayConvertibleTests.swift */; };
87+
5EF64039204145A80007BDD2 /* NSAttributedString+PGLKeyedArchivingUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 5EF64037204145A80007BDD2 /* NSAttributedString+PGLKeyedArchivingUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
88+
5EF6403A204145A80007BDD2 /* NSAttributedString+PGLKeyedArchivingUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EF64038204145A80007BDD2 /* NSAttributedString+PGLKeyedArchivingUtilities.m */; settings = {COMPILER_FLAGS = "-fobjc-arc-exceptions"; }; };
89+
5EF6403D204148B80007BDD2 /* NSBezierPath+PGLKeyedArchivingUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 5EF6403B204148B80007BDD2 /* NSBezierPath+PGLKeyedArchivingUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
90+
5EF6403E204148B80007BDD2 /* NSBezierPath+PGLKeyedArchivingUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EF6403C204148B80007BDD2 /* NSBezierPath+PGLKeyedArchivingUtilities.m */; settings = {COMPILER_FLAGS = "-fobjc-arc-exceptions"; }; };
91+
5EF64041204149DE0007BDD2 /* UIBezierPath+PGLKeyedArchivingUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 5EF6403F204149DE0007BDD2 /* UIBezierPath+PGLKeyedArchivingUtilities.h */; settings = {ATTRIBUTES = (Public, ); }; };
92+
5EF64042204149DE0007BDD2 /* UIBezierPath+PGLKeyedArchivingUtilities.m in Sources */ = {isa = PBXBuildFile; fileRef = 5EF64040204149DE0007BDD2 /* UIBezierPath+PGLKeyedArchivingUtilities.m */; settings = {COMPILER_FLAGS = "-fobjc-arc-exceptions"; }; };
8793
5EFE9193203F6CF900E21BAA /* LegacyPlaygroundLoggerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5ECE8F901FFCD2A70034D9BC /* LegacyPlaygroundLoggerTests.swift */; };
8894
5EFE919B203F6DD700E21BAA /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EFE919A203F6DD700E21BAA /* AppDelegate.swift */; };
8995
5EFE919D203F6DD700E21BAA /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EFE919C203F6DD700E21BAA /* ViewController.swift */; };
@@ -251,6 +257,12 @@
251257
5ECE8F901FFCD2A70034D9BC /* LegacyPlaygroundLoggerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyPlaygroundLoggerTests.swift; sourceTree = "<group>"; };
252258
5EE3867320352F3200D625F0 /* CGFloat+CustomOpaqueLoggable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "CGFloat+CustomOpaqueLoggable.swift"; sourceTree = "<group>"; };
253259
5EF581512041384700AC14FE /* CustomPlaygroundDisplayConvertibleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CustomPlaygroundDisplayConvertibleTests.swift; sourceTree = "<group>"; };
260+
5EF64037204145A80007BDD2 /* NSAttributedString+PGLKeyedArchivingUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSAttributedString+PGLKeyedArchivingUtilities.h"; sourceTree = "<group>"; };
261+
5EF64038204145A80007BDD2 /* NSAttributedString+PGLKeyedArchivingUtilities.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSAttributedString+PGLKeyedArchivingUtilities.m"; sourceTree = "<group>"; };
262+
5EF6403B204148B80007BDD2 /* NSBezierPath+PGLKeyedArchivingUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSBezierPath+PGLKeyedArchivingUtilities.h"; sourceTree = "<group>"; };
263+
5EF6403C204148B80007BDD2 /* NSBezierPath+PGLKeyedArchivingUtilities.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSBezierPath+PGLKeyedArchivingUtilities.m"; sourceTree = "<group>"; };
264+
5EF6403F204149DE0007BDD2 /* UIBezierPath+PGLKeyedArchivingUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIBezierPath+PGLKeyedArchivingUtilities.h"; sourceTree = "<group>"; };
265+
5EF64040204149DE0007BDD2 /* UIBezierPath+PGLKeyedArchivingUtilities.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIBezierPath+PGLKeyedArchivingUtilities.m"; sourceTree = "<group>"; };
254266
5EFE9189203F6CC400E21BAA /* PlaygroundLoggerTests_iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = PlaygroundLoggerTests_iOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
255267
5EFE918D203F6CC400E21BAA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
256268
5EFE9198203F6DD700E21BAA /* PlaygroundLoggerTestHost_iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PlaygroundLoggerTestHost_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -436,6 +448,8 @@
436448
children = (
437449
5E2756311FC48FD300B69C83 /* NSRange+KeyedArchiveOpaqueRepresentation.swift */,
438450
5E2756331FC490AF00B69C83 /* NSAttributedString+KeyedArchiveOpaqueRepresentation.swift */,
451+
5EF64037204145A80007BDD2 /* NSAttributedString+PGLKeyedArchivingUtilities.h */,
452+
5EF64038204145A80007BDD2 /* NSAttributedString+PGLKeyedArchivingUtilities.m */,
439453
5E2756351FC4CC2600B69C83 /* URL+TaggedOpaqueRepresentation.swift */,
440454
);
441455
path = Foundation;
@@ -445,6 +459,8 @@
445459
isa = PBXGroup;
446460
children = (
447461
5E27563E1FC4D31D00B69C83 /* NSBezierPath+KeyedArchiveOpaqueRepresentation.swift */,
462+
5EF6403B204148B80007BDD2 /* NSBezierPath+PGLKeyedArchivingUtilities.h */,
463+
5EF6403C204148B80007BDD2 /* NSBezierPath+PGLKeyedArchivingUtilities.m */,
448464
5E2756901FCF967300B69C83 /* NSBitmapImageRep+OpaqueImageRepresentable.swift */,
449465
5E2756431FC4D60600B69C83 /* NSImage+OpaqueImageRepresentable.swift */,
450466
5E2756471FC4DE1500B69C83 /* NSView+OpaqueImageRepresentable.swift */,
@@ -456,6 +472,8 @@
456472
isa = PBXGroup;
457473
children = (
458474
5E2756411FC4D3BF00B69C83 /* UIBezierPath+KeyedArchiveOpaqueRepresentation.swift */,
475+
5EF6403F204149DE0007BDD2 /* UIBezierPath+PGLKeyedArchivingUtilities.h */,
476+
5EF64040204149DE0007BDD2 /* UIBezierPath+PGLKeyedArchivingUtilities.m */,
459477
5E2756491FC4DF0200B69C83 /* UIImage+OpaqueImageRepresentable.swift */,
460478
5E27564B1FC4E07600B69C83 /* UIView+OpaqueImageRepresentable.swift */,
461479
);
@@ -623,6 +641,9 @@
623641
buildActionMask = 2147483647;
624642
files = (
625643
5E184718202BB80200F01AD1 /* PGLConcurrentMap.h in Headers */,
644+
5EF64041204149DE0007BDD2 /* UIBezierPath+PGLKeyedArchivingUtilities.h in Headers */,
645+
5EF6403D204148B80007BDD2 /* NSBezierPath+PGLKeyedArchivingUtilities.h in Headers */,
646+
5EF64039204145A80007BDD2 /* NSAttributedString+PGLKeyedArchivingUtilities.h in Headers */,
626647
5E2646381FB64876002DC6B6 /* PlaygroundLogger.h in Headers */,
627648
);
628649
runOnlyForDeploymentPostprocessing = 0;
@@ -864,6 +885,7 @@
864885
5E27563D1FC4D17F00B69C83 /* CGColor+KeyedArchiveOpaqueRepresentation.swift in Sources */,
865886
5E2756531FC4EC6200B69C83 /* CustomOpaqueLoggable.swift in Sources */,
866887
5E2756671FC51C9C00B69C83 /* NSRange+CustomOpaqueLoggable.swift in Sources */,
888+
5EF6403A204145A80007BDD2 /* NSAttributedString+PGLKeyedArchivingUtilities.m in Sources */,
867889
5E27562A1FC48C7D00B69C83 /* Bool+TaggedOpaqueRepresentation.swift in Sources */,
868890
5E2755D11FB6619800B69C83 /* LogPacket.swift in Sources */,
869891
5E2756651FC51C7700B69C83 /* NSString+CustomOpaqueLoggable.swift in Sources */,
@@ -901,6 +923,7 @@
901923
5E27563F1FC4D31D00B69C83 /* NSBezierPath+KeyedArchiveOpaqueRepresentation.swift in Sources */,
902924
5E2756421FC4D3BF00B69C83 /* UIBezierPath+KeyedArchiveOpaqueRepresentation.swift in Sources */,
903925
5E2756741FC5205F00B69C83 /* CGImage+OpaqueImageRepresentable.swift in Sources */,
926+
5EF6403E204148B80007BDD2 /* NSBezierPath+PGLKeyedArchivingUtilities.m in Sources */,
904927
5E27567C1FCF423400B69C83 /* NSColor+CustomOpaqueLoggable.swift in Sources */,
905928
5E2756821FCF439D00B69C83 /* NSImage+CustomOpaqueLoggable.swift in Sources */,
906929
5E2755D91FB6836800B69C83 /* LogEncoder.swift in Sources */,
@@ -916,6 +939,7 @@
916939
5E2756701FC51FCB00B69C83 /* CGColor+OpaquePlaygroundLoggable.swift in Sources */,
917940
5E2756341FC490AF00B69C83 /* NSAttributedString+KeyedArchiveOpaqueRepresentation.swift in Sources */,
918941
5E2756631FC51C3E00B69C83 /* URL+CustomOpaqueLoggable.swift in Sources */,
942+
5EF64042204149DE0007BDD2 /* UIBezierPath+PGLKeyedArchivingUtilities.m in Sources */,
919943
5E2755CF1FB657F200B69C83 /* LogEntry.swift in Sources */,
920944
5E2756221FC4873000B69C83 /* UInt64+TaggedOpaqueRepresentation.swift in Sources */,
921945
5E2756281FC4895100B69C83 /* Double+TaggedOpaqueRepresentation.swift in Sources */,

PlaygroundLogger/PlaygroundLogger/OpaqueRepresentations/AppKit/NSBezierPath+KeyedArchiveOpaqueRepresentation.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -19,8 +19,13 @@
1919
extension NSBezierPath: KeyedArchiveOpaqueRepresentation {
2020
var tag: String { return bezierPathTag }
2121

22-
func encodeOpaqueRepresentation(with encoder: NSCoder, usingFormat format: LogEncoder.Format) {
23-
encoder.encode(self, forKey: "root")
22+
func encodeOpaqueRepresentation(with encoder: NSCoder, usingFormat format: LogEncoder.Format) throws {
23+
do {
24+
try self.encodeForLogEntry(using: encoder)
25+
}
26+
catch {
27+
throw LoggingError.encodingFailure(reason: "Failed to encode NSBezierPath using NSKeyedArchiver")
28+
}
2429
}
2530
}
2631
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===--- NSBezierPath+PGLKeyedArchivingUtilities.h ------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#import <TargetConditionals.h>
14+
15+
#if TARGET_OS_OSX
16+
17+
#import <AppKit/AppKit.h>
18+
19+
NS_ASSUME_NONNULL_BEGIN
20+
21+
@interface NSBezierPath (PGLKeyedArchivingUtilities)
22+
23+
- (BOOL)pgl_encodeForLogEntryUsingEncoder:(NSCoder *)coder error:(NSError **)outError NS_SWIFT_NAME(encodeForLogEntry(using:));
24+
25+
@end
26+
27+
NS_ASSUME_NONNULL_END
28+
29+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===--- NSBezierPath+PGLKeyedArchivingUtilities.h ------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#import <PlaygroundLogger/NSBezierPath+PGLKeyedArchivingUtilities.h>
14+
15+
#if TARGET_OS_OSX
16+
17+
@implementation NSBezierPath (PGLKeyedArchivingUtilities)
18+
19+
- (BOOL)pgl_encodeForLogEntryUsingEncoder:(NSCoder *)coder error:(NSError **)outError {
20+
@try {
21+
[coder encodeObject:self forKey:@"root"];
22+
}
23+
@catch (...) {
24+
if (outError) {
25+
*outError = [NSError errorWithDomain:@"PGLErrorDomain" code:-1 userInfo:@{
26+
NSLocalizedFailureReasonErrorKey: @"Encountered an exception when encoding an NSBezierPath",
27+
}];
28+
}
29+
return NO;
30+
}
31+
32+
return YES;
33+
}
34+
35+
@end
36+
37+
#endif

PlaygroundLogger/PlaygroundLogger/OpaqueRepresentations/Foundation/NSAttributedString+KeyedArchiveOpaqueRepresentation.swift

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -17,7 +17,12 @@ fileprivate let attributedStringTag = "ASTR"
1717
extension NSAttributedString: KeyedArchiveOpaqueRepresentation {
1818
var tag: String { return attributedStringTag }
1919

20-
func encodeOpaqueRepresentation(with encoder: NSCoder, usingFormat format: LogEncoder.Format) {
21-
encoder.encode(self, forKey: "root")
20+
func encodeOpaqueRepresentation(with encoder: NSCoder, usingFormat format: LogEncoder.Format) throws {
21+
do {
22+
try self.encodeForLogEntry(using: encoder)
23+
}
24+
catch {
25+
throw LoggingError.encodingFailure(reason: "Failed to encode NSAttributedString using NSKeyedArchiver")
26+
}
2227
}
2328
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===--- NSAttributedString+PGLKeyedArchivingUtilities.h ------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#import <Foundation/Foundation.h>
14+
15+
NS_ASSUME_NONNULL_BEGIN
16+
17+
@interface NSAttributedString (PGLKeyedArchivingUtilities)
18+
19+
- (BOOL)pgl_encodeForLogEntryUsingEncoder:(NSCoder *)coder error:(NSError **)outError NS_SWIFT_NAME(encodeForLogEntry(using:));
20+
21+
@end
22+
23+
NS_ASSUME_NONNULL_END
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//===--- NSAttributedString+PGLKeyedArchivingUtilities.m ------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#import <PlaygroundLogger/NSAttributedString+PGLKeyedArchivingUtilities.h>
14+
15+
@implementation NSAttributedString (PGLKeyedArchivingUtilities)
16+
17+
- (BOOL)pgl_encodeForLogEntryUsingEncoder:(NSCoder *)coder error:(NSError **)outError {
18+
@try {
19+
[coder encodeObject:self forKey:@"root"];
20+
}
21+
@catch (...) {
22+
if (outError) {
23+
*outError = [NSError errorWithDomain:@"PGLErrorDomain" code:-1 userInfo:@{
24+
NSLocalizedFailureReasonErrorKey: @"Encountered an exception when encoding an NSAttributedString",
25+
}];
26+
}
27+
return NO;
28+
}
29+
30+
return YES;
31+
}
32+
33+
@end

PlaygroundLogger/PlaygroundLogger/OpaqueRepresentations/UIKit/UIBezierPath+KeyedArchiveOpaqueRepresentation.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
//===--- NSBezierPath+KeyedArchiveOpaqueRepresentation.swift --------------===//
1+
//===--- UIBezierPath+KeyedArchiveOpaqueRepresentation.swift --------------===//
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2017-2018 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See http://swift.org/LICENSE.txt for license information
@@ -19,8 +19,13 @@
1919
extension UIBezierPath: KeyedArchiveOpaqueRepresentation {
2020
var tag: String { return bezierPathTag }
2121

22-
func encodeOpaqueRepresentation(with encoder: NSCoder, usingFormat format: LogEncoder.Format) {
23-
encoder.encode(self, forKey: "root")
22+
func encodeOpaqueRepresentation(with encoder: NSCoder, usingFormat format: LogEncoder.Format) throws {
23+
do {
24+
try self.encodeForLogEntry(using: encoder)
25+
}
26+
catch {
27+
throw LoggingError.encodingFailure(reason: "Failed to encode UIBezierPath using NSKeyedArchiver")
28+
}
2429
}
2530
}
2631
#endif
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===--- UIBezierPath+PGLKeyedArchivingUtilities.h ------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#import <TargetConditionals.h>
14+
15+
#if TARGET_OS_IOS || TARGET_OS_TV
16+
17+
#import <UIKit/UIKit.h>
18+
19+
NS_ASSUME_NONNULL_BEGIN
20+
21+
@interface UIBezierPath (PGLKeyedArchivingUtilities)
22+
23+
- (BOOL)pgl_encodeForLogEntryUsingEncoder:(NSCoder *)coder error:(NSError **)outError NS_SWIFT_NAME(encodeForLogEntry(using:));
24+
25+
@end
26+
27+
NS_ASSUME_NONNULL_END
28+
29+
#endif
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===--- UIBezierPath+PGLKeyedArchivingUtilities.m ------------------------===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2018 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See http://swift.org/LICENSE.txt for license information
9+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#import <PlaygroundLogger/UIBezierPath+PGLKeyedArchivingUtilities.h>
14+
15+
#if TARGET_OS_IOS || TARGET_OS_TV
16+
17+
@implementation UIBezierPath (PGLKeyedArchivingUtilities)
18+
19+
- (BOOL)pgl_encodeForLogEntryUsingEncoder:(NSCoder *)coder error:(NSError **)outError {
20+
@try {
21+
[coder encodeObject:self forKey:@"root"];
22+
}
23+
@catch (...) {
24+
if (outError) {
25+
*outError = [NSError errorWithDomain:@"PGLErrorDomain" code:-1 userInfo:@{
26+
NSLocalizedFailureReasonErrorKey: @"Encountered an exception when encoding an UIBezierPath",
27+
}];
28+
}
29+
return NO;
30+
}
31+
32+
return YES;
33+
}
34+
35+
@end
36+
37+
#endif

0 commit comments

Comments
 (0)