Questions tagged [nssecurecoding]

Conforming to the NSSecureCoding protocol indicates that an object handles encoding and decoding instances of itself in a manner that is robust against object substitution attacks.

Conforming to the NSSecureCoding protocol indicates that an object handles encoding and decoding instances of itself in a manner that is robust against object substitution attacks.

Click Here for class reference.

48 questions
31
votes
3 answers

When to use NSSecureCoding

I'm learning about the NSSecureCoding protocol introduced by Apple in iOS 6. From my understanding so far, it should be used whenever a class encodes/decodes instances of itself, in order to prevent substitution attacks. I'm wondering whether it…
Gabriele Petronella
  • 106,943
  • 21
  • 217
  • 235
17
votes
3 answers

NSSecureCoding trouble with collections of custom class

I am having trouble with adopting NSSecureCoding. I encode an array containing objects of my custom class, which adopts NSSecureCoding properly. When I decode it, passing the class NSArray (which is the class of the object I encoded), it throws an…
user102008
  • 30,736
  • 10
  • 83
  • 104
12
votes
1 answer

Enforcing types with NSSecureCoding

I decided to use NSSecureCoding over NSCoding, but I'm having trouble getting it to work. I would expect the following code to fail, since I'm encoding an NSString but attempting to decode an NSNumber. The object is initialized without throwing an…
Christian Schnorr
  • 10,768
  • 8
  • 48
  • 83
11
votes
2 answers

Crash when adopting NSSecureUnarchiveFromDataTransformer for a Transformable property

In iOS 12 Apple introduced NSSecureUnarchiveFromDataTransformerName for use on CoreData model entities' Transformable properties. I used to keep the Transformer Name field empty, which implicitly used NSKeyedUnarchiveFromDataTransformerName. This…
Adar Hefer
  • 1,514
  • 1
  • 12
  • 18
11
votes
1 answer

UNMutableNotificationContent with custom object in userinfo

I want to use a cutom object in userinfo of a UNMutableNotificationContent but it doesn’t work. When I put a custom object in userinfo, notification is not fired. With this code, a notification is fired: let content =…
squall2022
  • 214
  • 4
  • 9
10
votes
4 answers

Strange behavoir when decoding an NSArray via NSSecureCoding

i spent all afternoon banging my head against the wall trying to figure out why decoding of this class was failing. the class has a property that is an NSArray of Foo objects. Foo conforms to NSSecureCoding, and i have successfully encoded and…
Ben H
  • 3,855
  • 1
  • 26
  • 33
9
votes
1 answer

How to use NSSecureCoding with id objects

I'm creating a linked list and using containers to group the object, next, and previous properties. Like Foundation collections, I'd like it to implement NSSecureCoding. Here's the declaration: @interface ListContainer : NSObject
André Fratelli
  • 5,920
  • 7
  • 46
  • 87
7
votes
1 answer

How to decode string using NSSecureCoding in Swift 3?

I am currently trying the iOS 10 Beta and decided to convert my Swift code to Swift 3. Until now, I was able to securely decode a String using coder.decodeObjectOfClass(NSString.self, forKey: CoderKeys.code) as! String After the conversion to Swift…
Paco1
  • 758
  • 6
  • 18
5
votes
1 answer

Using decodeObject(of: forKey:) to decode an object that conforms to a protocol

I have an Objective-C protocol that requires conformance to NSSecureCoding: @protocol MyProtocol … @end I have a parent object that stores a reference to an object conforming to MyProtocol, and I would like the parent…
Jeff V
  • 571
  • 1
  • 5
  • 17
4
votes
1 answer

How to fix the ''NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release' error?

I am using Core Data for persistent storage and I am getting the error listed below. I have looked up the message and I know it has something to do with the fact that I am using the transformable and a custom class. Despite my research I am not sure…
Part_Time_Nerd
  • 994
  • 7
  • 26
  • 56
4
votes
4 answers

`supportsSecureCoding` crashes when using Optimize for Speed option

I'm having trouble creating classes that uses NSSecureCoding and its subclasses. class ClassA: NSObject, NSSecureCoding { public static var supportsSecureCoding: Bool { return true } } class ClassB: ClassA { public static var…
Genki
  • 3,055
  • 2
  • 29
  • 42
3
votes
1 answer

Changing NSValueTransformer to NSSecureUnarchiveFromDataTransformer for Core Data warning

In my Core Data schema, I have a 'transformable' attribute in an entity, which is using a NSValueTransformer, the purpose of which is to convert a UIImage into NSData with some compression. From this attribute, I had recently started getting these…
Z S
  • 7,039
  • 12
  • 53
  • 105
3
votes
1 answer

How to cast NSSecureCoding to MKMapItem in Action Extension

I'm trying to make an Action Extension for my app where the user can add his current location along with some other data. I debugged the extension after sharing a location with Apple Maps App and found out that Maps sends four providers with…
cameloper
  • 297
  • 1
  • 3
  • 16
3
votes
1 answer

Must NSSecureCoding-implementing classes be in shared framework to work with XPC?

While following Creating XPC Services guide in Swift and trying to pass custom Foo class I found that in order for this to work it must be in a dynamic library. When it's embedded into both targets the connection to service fails with 4097 code.…
Ian Bytchek
  • 8,804
  • 6
  • 46
  • 72
3
votes
1 answer

How can NSDictionary support NSSecureCoding, when it doesn't know it's future content

By Apple specs., when a class support NSSecureCoding, it should use decodeObjectOfClass:forKey: in it's initWithCoder but as the dictionary has no clue about it's content, how can it support secure coding? in contrary to a custom object, where the…
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179
1
2 3 4