Skip to content

Commit

Permalink
Fix NSKeyedUnarchiver error unarchiving object with different class t…
Browse files Browse the repository at this point in the history
…hat String, Data, URL (#20)
  • Loading branch information
vpeschenkov committed Dec 11, 2023
1 parent 8e7e970 commit 18a0621
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -8,6 +8,10 @@
### Fixed for any bug fixes.
```

# 1.2.1
### Fixed:
- Fixed NSKeyedUnarchiver error unarchiving object with different class that String, Data, URL

# 1.2.0
### Fixed:
- Xcode15 support and warnings
Expand Down
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -78,15 +78,15 @@ public func rawObject(forKey defaultName: String) -> Any?
it, simply add the following line to your Podfile:

```ruby
pod 'SecureDefaults', '1.1.0' # Swift 5.0
pod 'SecureDefaults', '1.2.1' # Swift 5.0
```

### [Carthage](https://github.com/Carthage/Carthage)

Add this to `Cartfile`

```ruby
github "vpeschenkov/SecureDefaults" == 1.1.0
github "vpeschenkov/SecureDefaults" == 1.2.1
```

```sh
Expand All @@ -104,7 +104,7 @@ import PackageDescription
let package = Package(
name: "YourProject",
dependencies: [
.package(url: "https://github.com/vpeschenkov/SecureDefaults", "1.2.0")
.package(url: "https://github.com/vpeschenkov/SecureDefaults", "1.2.1")
],
targets: [
.target(name: "YourProject", dependencies: ["SecureDefaults"])
Expand Down
2 changes: 1 addition & 1 deletion SecureDefaults.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'SecureDefaults'
s.version = '1.2.0'
s.version = '1.2.1'
s.summary = 'A lightweight wrapper over UserDefaults/NSUserDefaults with an extra AES-256 encryption layer'
s.homepage = 'https://github.com/vpeschenkov/SecureDefaults'
s.license = { :type => 'MIT', :file => 'LICENSE' }
Expand Down
8 changes: 1 addition & 7 deletions Sources/SecureDefaults/SecureDefaults.swift
Expand Up @@ -262,13 +262,7 @@ public class SecureDefaults: UserDefaults {
let object = super.object(forKey: defaultName)
guard let object = object as? Data,
let decrypted = try? decrypter?.decrypt(object),
let data = try? NSKeyedUnarchiver.unarchivedObject(ofClasses:
[
NSString.self,
NSData.self,
NSURL.self,
],
from: decrypted) else {
let data = try? NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(decrypted) else {
// TODO: Add some logging or fatal error?
return nil
}
Expand Down

0 comments on commit 18a0621

Please sign in to comment.