You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Foundation/NSCoder.swift
+38-20Lines changed: 38 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,16 @@
7
7
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
8
8
//
9
9
10
+
extensionNSCoder{
11
+
/*!
12
+
Describes the action an NSCoder should take when it encounters decode failures (e.g. corrupt data) for non-TopLevel decodes. Darwin platfrom supports exceptions here, and there may be other approaches supported in the future, so its included for completeness.
13
+
*/
14
+
publicenumDecodingFailurePolicy:Int{
15
+
case setErrorAndReturn
16
+
}
17
+
}
18
+
19
+
10
20
publicprotocolNSCoding{
11
21
func encode(with aCoder:NSCoder)
12
22
init?(coder aDecoder:NSCoder)
@@ -30,23 +40,23 @@ open class NSCoder : NSObject {
30
40
NSRequiresConcreteImplementation()
31
41
}
32
42
33
-
openfuncencodeDataObject(_ data:Data){
43
+
openfuncencode(_ data:Data){
34
44
NSRequiresConcreteImplementation()
35
45
}
36
46
37
47
openfunc decodeValue(ofObjCType type:UnsafePointer<Int8>, at data:UnsafeMutableRawPointer){
iflet info = aDecoder.decodeObjectOfClasses([NSSet.self,NSDictionary.self,NSArray.self,NSString.self,NSNumber.self,NSData.self,NSURL.self], forKey:"NSUserInfo")as?NSDictionary{
iflet info = aDecoder.decodeObject(of:[NSSet.self,NSDictionary.self,NSArray.self,NSString.self,NSNumber.self,NSData.self,NSURL.self], forKey:"NSUserInfo")as?NSDictionary{
60
60
varfilteredUserInfo=[String : Any]()
61
61
// user info must be filtered so that the keys are all strings
/// If encoding has not yet finished, then invoking this property will call finishEncoding and return the data. If you initialized the keyed archiver with a specific mutable data instance, then it will be returned from this property after finishEncoding is called.
205
+
openvarencodedData:Data{
206
+
NSUnimplemented()
207
+
}
198
208
199
209
openfunc finishEncoding(){
200
210
if _flags.contains(ArchiverFlags.finishedEncoding){
@@ -746,7 +756,7 @@ open class NSKeyedArchiver : NSCoder {
746
756
_encodeValue(NSNumber(value: intv), forKey: key)
747
757
}
748
758
749
-
openoverridefuncencodeDataObject(_ data:Data){
759
+
openoverridefuncencode(_ data:Data){
750
760
// this encodes as a reference to an NSData object rather than encoding inline
0 commit comments