UIPasteboard crashes when settings nil to the `string` property

Originator:samsoffes
Number:rdar://36063433 Date Originated:December 14 2017, 5:18 PM
Status:Open Resolved:
Product:iOS + SDK Product Version:11
Classification:Crash Reproducible:Always
 
Area:
UIKit

Summary:

Setting `nil` to `UIPasteboard.general.string` will crash. This is very misleading since the type is an optional and the documentation doesn't note that this will crash.

Steps to Reproduce:

UIPasteboard.general.string = nil

Expected Results:

It would do nothing or clear the contents of the clipboard.

Actual Results:

It crashes. Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[_UIConcretePasteboard setString:]: Argument is not an object of type NSString [(null)]'

Version/Build:

iOS 11

Configuration:

Xcode 9.2 (9C40b)

Notes:

See attached sample project and crash log.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!