{"__v":6,"_id":"56740186f79ca90d00ad2f68","category":{"__v":3,"_id":"5674017bf79ca90d00ad2f67","pages":["56740186f79ca90d00ad2f68","5674019122cd7e0d00fada83","567401b522cd7e0d00fada86"],"project":"5672fc989996590d00c22c65","version":"5672fc989996590d00c22c68","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2015-12-18T12:52:11.346Z","from_sync":false,"order":3,"slug":"ios-only-operations","title":"iOS only Operations"},"project":"5672fc989996590d00c22c65","user":"5654ea8be0d82b0d00ab5747","version":{"__v":7,"_id":"5672fc989996590d00c22c68","project":"5672fc989996590d00c22c65","createdAt":"2015-12-17T18:19:04.699Z","releaseDate":"2015-12-17T18:19:04.699Z","categories":["5672fc999996590d00c22c69","567301169d4c060d009da8b3","56730183547bee0d00997d1a","5673018a06b19d0d0010691b","567301b53054630d00fe9288","567400638565060d009a86fb","5674017bf79ca90d00ad2f67"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.5.0","version":"2.5.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2015-12-18T12:52:22.199Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"`AlertOperation` is an operation which can be used to present a `UIAlertController`.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"// Presenting an alert from inside a view controller\\nlet alert = AlertOperation(presentAlertFrom: self)\\n\\n// Configure the alert's title and message\\nalert.title = NSLocalizedString(\\\"A title!\\\", comment: \\\"A Title!\\\")\\nalert.message = NSLocalizedString(\\\"This is a message.\\\", comment: \\\"This is a message.\\\")\\n\\n// Add actions, if no actions are added, a default\\n// action (Okay) with no block is added.\\nalert.addActionWithTitle(NSLocalizedString(\\\"Ok\\\", comment: \\\"Ok\\\")) { _ in\\n    print(\\\"Did press ok!\\\")\\n}\\n\\n// Add it to the queue...\\nqueue.addOperation(alert)\",\n      \"language\": \"swift\",\n      \"name\": \"show alert\"\n    }\n  ]\n}\n[/block]\nA nice feature of this is that the alert operation is mutually exclusive, which means that no other `AlertOperation` instances can be executed until it is dismissed.\n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"The `UserConfirmationCondition` is essentially an `AlertOperation` but used as a condition.\",\n  \"title\": \"UserConfirmationCondition\"\n}\n[/block]","excerpt":"","slug":"alert-operation","type":"basic","title":"Alert Operation"}
`AlertOperation` is an operation which can be used to present a `UIAlertController`. [block:code] { "codes": [ { "code": "// Presenting an alert from inside a view controller\nlet alert = AlertOperation(presentAlertFrom: self)\n\n// Configure the alert's title and message\nalert.title = NSLocalizedString(\"A title!\", comment: \"A Title!\")\nalert.message = NSLocalizedString(\"This is a message.\", comment: \"This is a message.\")\n\n// Add actions, if no actions are added, a default\n// action (Okay) with no block is added.\nalert.addActionWithTitle(NSLocalizedString(\"Ok\", comment: \"Ok\")) { _ in\n print(\"Did press ok!\")\n}\n\n// Add it to the queue...\nqueue.addOperation(alert)", "language": "swift", "name": "show alert" } ] } [/block] A nice feature of this is that the alert operation is mutually exclusive, which means that no other `AlertOperation` instances can be executed until it is dismissed. [block:callout] { "type": "info", "body": "The `UserConfirmationCondition` is essentially an `AlertOperation` but used as a condition.", "title": "UserConfirmationCondition" } [/block]