Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copying UIView using NSKeyedArchiver throws NSInvalidUnarchiveOperationException

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

like image 920
Yadvendar Avatar asked Mar 19 '13 16:03

Yadvendar


1 Answers

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.

like image 157
McDonal_11 Avatar answered Oct 17 '22 12:10

McDonal_11