Xcode 9 Playgrounds and UIRefreshControl

Hey,


The Playgrounds doesn't seem to cope with UIRefreshControl. On my Xcode when I simply import UIKit and call the init for UIRefreshControl it fails with an error like:

libc++abi.dylib: terminating with uncaught exception of type NSException


I initially thought that it's a Deployment Target issue, as UIRefereshControl is iOS 10+, but other iOS 10+ APIs seems to be fine.


Is there a bug?

libc++abi.dylib: terminating with uncaught exception of type NSException

Interesting. This indicates that

UIRefreshControl
has thrown a language exception. Playgrounds doesn’t make it easy to see what that exception was, but some spelunking in the Console app reveals this:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIRefreshControl was unable to find its associated scroll view'

Hopefully that hint will allow you to make progress. If not, my recommendation is that you ask about this exception over in Apple Frameworks > Cocoa Touch, because this is clearly something very specific to

UIRefreshControl
.

ps I also recommend that you file a bug against Xcode’s playground support requesting that it provide more info when you hit a language exception like this. Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
Xcode 11.6: Strongly depending on what you need to achieve you can possibly workaround the crash with something like this:
Code Block swift
let tableView = UITableView(frame: CGRect(origin: .zero, size: CGSize(width: 400, height: 200)))
tableView.refreshControl = UIRefreshControl(frame: tableView.bounds)
tableView.backgroundColor = .systemGreen
let refreshControl = tableView.refreshControl
refreshControl.map { tableView.addSubview($0) }
refreshControl?.backgroundColor = .systemBlue
refreshControl?.tintColor = .darkText
PlaygroundPage.current.liveView = tableView



Xcode 9 Playgrounds and UIRefreshControl
 
 
Q