Copying UIView using NSKeyedArchiver throws NSInvalidUnarchiveOperationException
Asked Answered
S

1

8

Using this to copy UIView

UIView copyOfView = 
[NSKeyedUnarchiver unarchiveObjectWithData:[NSKeyedArchiver archivedDataWithRootObject:originalView]]

This throws the following error:

NSInvalidUnarchiveOperationException

[NSKeyedUnarchiver decodeBoolForKey]: value for key (UIHighlighted) is not a boolean

Scholl answered 19/3, 2013 at 16:31 Comment(1)
Any solution for this??Abolition
A
3

If we are using Archive/Unarchive with UIImageView , I am facing error, though I fixed that highlight issue.

let NewView = whichView.snapshotView(afterScreenUpdates: true)!

The above line will give you best solution.

Abolition answered 3/8, 2017 at 13:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.