{"id":16907011,"url":"https://github.com/ashfurrow/uialertcontroller-example","last_synced_at":"2025-04-11T15:37:02.469Z","repository":{"id":20485705,"uuid":"23763806","full_name":"ashfurrow/UIAlertController-Example","owner":"ashfurrow","description":"A demonstration of how to use Apple's hot new UIAlertController class","archived":false,"fork":false,"pushed_at":"2014-09-07T17:30:43.000Z","size":140,"stargazers_count":20,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T11:49:19.955Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://ashfurrow.com/blog/uialertviewcontroller-example","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ashfurrow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-07T15:54:08.000Z","updated_at":"2019-08-13T15:50:12.000Z","dependencies_parsed_at":"2022-07-31T21:38:12.242Z","dependency_job_id":null,"html_url":"https://github.com/ashfurrow/UIAlertController-Example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2FUIAlertController-Example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2FUIAlertController-Example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2FUIAlertController-Example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashfurrow%2FUIAlertController-Example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashfurrow","download_url":"https://codeload.github.com/ashfurrow/UIAlertController-Example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248432274,"owners_count":21102344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T18:45:37.282Z","updated_at":"2025-04-11T15:37:02.445Z","avatar_url":"https://github.com/ashfurrow.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"UIAlertController-Example\n=========================\n\nSo Apple added this new [UIAlertViewController](https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIAlertController_class/) class in iOS 8. Cool, right? I mean, it came with next to no sample code despite replacing `UIAlertView` and `UIActionSheet`, which are now deprecated, so. \n\nI had a hard time figuring out how to get the text field's text value. The only solution I found was to store the `UITextField` instance in a property of the view controller presenting it, which is a very ... Objective-C way of doing things. We can do better.\n\nSo I wrote a [blog post](http://ashfurrow.com/blog/uialertviewcontroller-example) exploring the API. Here's what I came up with. \n\n```swift\nlet promptController = UIAlertController(title: \"Type Something\", message: nil, preferredStyle: .Alert)\nlet ok = UIAlertAction(title: \"OK\", style: .Default, handler: { (action) -\u003e Void in\n    println(\"\\(alertViewControllerTextField?.text)\")\n})\nlet cancel = UIAlertAction(title: \"Cancel\", style: .Cancel) { (action) -\u003e Void in\n}\npromptController.addAction(ok)\npromptController.addAction(cancel)\npromptController.addTextFieldWithConfigurationHandler { (textField) -\u003e Void in\n    alertViewControllerTextField = textField\n}\npresentViewController(promptController, animated: true, completion: nil)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashfurrow%2Fuialertcontroller-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashfurrow%2Fuialertcontroller-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashfurrow%2Fuialertcontroller-example/lists"}