{"id":308,"date":"2017-08-05T07:48:40","date_gmt":"2017-08-05T06:48:40","guid":{"rendered":"http:\/\/www.danieledavi.com\/blog\/?p=308"},"modified":"2017-08-03T23:00:36","modified_gmt":"2017-08-03T22:00:36","slug":"android-toast-equivalent-in-ios","status":"publish","type":"post","link":"https:\/\/www.danieledavi.com\/blog\/2017\/08\/android-toast-equivalent-in-ios\/","title":{"rendered":"Android Toast equivalent in iOS"},"content":{"rendered":"<p>If you wonder what the Java Toast equivalent of this iOS Objective C event would be than you are in the right place. Below is a sample of what I have written for iOS and Xamarin.iOS. This behave pretty much the&nbsp;same as Alert in Java using a Toast in place of the iOS UIAlert.<\/p>\n<p>In Objective C:<\/p>\n<pre class=\"default prettyprint prettyprinted\"><code><span class=\"typ\">NSString<\/span> <span class=\"pun\">*<\/span><span class=\"pln\">message <\/span><span class=\"pun\">=<\/span> <span class=\"pun\">@<\/span><span class=\"str\">\"Toast kind of message\"<\/span><span class=\"pun\">;<\/span>\r\n<span class=\"typ\">UIAlertView<\/span> <span class=\"pun\">*<\/span><span class=\"pln\">toast <\/span><span class=\"pun\">=<\/span> <span class=\"pun\">[[<\/span><span class=\"typ\">UIAlertView<\/span><span class=\"pln\"> alloc<\/span><span class=\"pun\">]<\/span><span class=\"pln\"> initWithTitle<\/span><span class=\"pun\">:<\/span><span class=\"kwd\">nil<\/span><span class=\"pln\">\r\n                                            message<\/span><span class=\"pun\">:<\/span><span class=\"pln\">message\r\n                                           <\/span><span class=\"kwd\">delegate<\/span><span class=\"pun\">:<\/span><span class=\"kwd\">nil<\/span><span class=\"pln\">\r\n                                  cancelButtonTitle<\/span><span class=\"pun\">:<\/span><span class=\"kwd\">nil<\/span><span class=\"pln\">\r\n                                  otherButtonTitles<\/span><span class=\"pun\">:<\/span><span class=\"kwd\">nil<\/span><span class=\"pun\">,<\/span> <span class=\"kwd\">nil<\/span><span class=\"pun\">];<\/span>\r\n<span class=\"pun\">[<\/span><span class=\"pln\">toast show<\/span><span class=\"pun\">];<\/span>\r\n<span class=\"kwd\">int<\/span><span class=\"pln\"> duration <\/span><span class=\"pun\">=<\/span> <span class=\"lit\">1<\/span><span class=\"pun\">;<\/span> <span class=\"com\">\/\/ in seconds<\/span><span class=\"pln\">\r\n\r\ndispatch_after<\/span><span class=\"pun\">(<\/span><span class=\"pln\">dispatch_time<\/span><span class=\"pun\">(<\/span><span class=\"pln\">DISPATCH_TIME_NOW<\/span><span class=\"pun\">,<\/span><span class=\"pln\"> duration <\/span><span class=\"pun\">*<\/span><span class=\"pln\"> NSEC_PER_SEC<\/span><span class=\"pun\">),<\/span><span class=\"pln\"> dispatch_get_main_queue<\/span><span class=\"pun\">(),<\/span> <span class=\"pun\">^{<\/span>\r\n<span class=\"pun\">[<\/span><span class=\"pln\">toast dismissWithClickedButtonIndex<\/span><span class=\"pun\">:<\/span><span class=\"lit\">0<\/span><span class=\"pln\"> animated<\/span><span class=\"pun\">:<\/span><span class=\"pln\">YES<\/span><span class=\"pun\">];<\/span>\r\n<span class=\"pun\">});<\/span><\/code><\/pre>\n<p>And if you are&nbsp;using <strong>Xamarin.IOS<\/strong> you can do like this:<\/p>\n<pre class=\"default prettyprint prettyprinted\"><code><span class=\"kwd\">new<\/span> <span class=\"typ\">UIAlertView<\/span><span class=\"pun\">(<\/span><span class=\"kwd\">null<\/span><span class=\"pun\">,<\/span><span class=\"pln\"> message<\/span><span class=\"pun\">,<\/span> <span class=\"kwd\">null<\/span><span class=\"pun\">,<\/span> <span class=\"str\">\"OK\"<\/span><span class=\"pun\">,<\/span> <span class=\"kwd\">null<\/span><span class=\"pun\">).<\/span><span class=\"typ\">Show<\/span><span class=\"pun\">();<\/span><\/code><\/pre>\n<p>using UIKit; is required.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you wonder what the Java Toast equivalent of this iOS Objective C event would be than you are in the right place. Below is a sample of what I have written for iOS and Xamarin.iOS. This behave pretty much the&nbsp;same as Alert in Java using a Toast in place of the iOS UIAlert. In [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[12],"tags":[139,135,138,136,140,133,134,137],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p90hsv-4Y","jetpack-related-posts":[{"id":303,"url":"https:\/\/www.danieledavi.com\/blog\/2017\/10\/as-canadian-as-possible-under-the-circumstances\/","url_meta":{"origin":308,"position":0},"title":"As Canadian as possible under the circumstances","author":"Daniele Dav\u00ec","date":"October 1, 2017","format":false,"excerpt":"One of the late Peter Gzowski's most amusing contributions to the never-ending search for Canadian identity was his contest to find this country's equivalent of \"as American as apple pie.\" So they made a national contest to come up with a new Canadian slogan and fill in the blank, \"As\u2026","rel":"","context":"In &quot;World&quot;","block_context":{"text":"World","link":"https:\/\/www.danieledavi.com\/blog\/category\/world\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":142,"url":"https:\/\/www.danieledavi.com\/blog\/2014\/09\/how-to-read-a-pop3-server-mail-folder-with-c\/","url_meta":{"origin":308,"position":1},"title":"How to read a Pop3 server mail folder with C#","author":"Daniele Dav\u00ec","date":"September 8, 2014","format":false,"excerpt":"Let's see how to read emails from a pop3 Server. After setting some variables, we'll create a connection to the Pop3 Server and we'll try to autenticate with user and password. After we'll take a bunch of messages and we'll start to iterate some operation per each message. The message\u2026","rel":"","context":"In &quot;.Net C#&quot;","block_context":{"text":".Net C#","link":"https:\/\/www.danieledavi.com\/blog\/category\/programming\/dot-net-c-sharp\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.danieledavi.com\/blog\/wp-content\/uploads\/2014\/09\/csharp-image.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":175,"url":"https:\/\/www.danieledavi.com\/blog\/2017\/05\/spam-how-everything-started\/","url_meta":{"origin":308,"position":2},"title":"SPAM: how everything started","author":"Daniele Dav\u00ec","date":"May 24, 2017","format":false,"excerpt":"\u00a0 The year was 1994. The Internet was young and there were a lot of clever people trying to figure out what to do with this new medium and exploring the possibilities that it opened up. In particular, there was a pair of attorneys in Arizona, Laurence Canter and Martha\u2026","rel":"","context":"In &quot;Courses Notes&quot;","block_context":{"text":"Courses Notes","link":"https:\/\/www.danieledavi.com\/blog\/category\/courses-notes\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.danieledavi.com\/blog\/wp-content\/uploads\/2017\/05\/6a00d83452d6c969e200e54f71aa398833-800wi-264x300.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":138,"url":"https:\/\/www.danieledavi.com\/blog\/2014\/09\/how-to-use-windows-registry-in-your-net-c-application\/","url_meta":{"origin":308,"position":3},"title":"How to use Windows registry in your .Net C# application","author":"Daniele Dav\u00ec","date":"September 5, 2014","format":false,"excerpt":"In this article I will show how to read and use in your .Net C# application informations stored in\u00a0the Windows registry. First of all let's see the easiest way to store some information in the server registry. You can use the \"regedit\" command to edit the register or you can\u2026","rel":"","context":"In &quot;.Net C#&quot;","block_context":{"text":".Net C#","link":"https:\/\/www.danieledavi.com\/blog\/category\/programming\/dot-net-c-sharp\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.danieledavi.com\/blog\/wp-content\/uploads\/2014\/09\/csharp-image.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":644,"url":"https:\/\/www.danieledavi.com\/blog\/2020\/12\/we-are-agile-how-it-started\/","url_meta":{"origin":308,"position":4},"title":"We Are Agile &#8211; How it started","author":"Daniele Dav\u00ec","date":"December 22, 2020","format":false,"excerpt":"What would you bring to my team? - Asked the hiring manager during one of the Microsoft interviews.Agile! - I answered right away. Few months later -fresh in my role in Microsoft as Azure Cloud Solution Architect- just back from my Microsoft Ready and induction bootcamp in Las Vegas, I\u2026","rel":"","context":"In &quot;Agile&quot;","block_context":{"text":"Agile","link":"https:\/\/www.danieledavi.com\/blog\/category\/agile-2\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":767,"url":"https:\/\/www.danieledavi.com\/blog\/2021\/03\/protect-your-work-from-home-space-from-toxicity\/","url_meta":{"origin":308,"position":5},"title":"Protect your work from home space from toxicity","author":"Daniele Dav\u00ec","date":"March 7, 2021","format":false,"excerpt":"A year ago, many countries took the first measures to tackle the emerging pandemic due to COVID-19. Lockdown, working from home, social distancing...Experts aren't certain if we'll be back to normality by 2022 or we will just prolong current habits and lifestyle to establish a new norm.\u00a0Will companies let employees\u2026","rel":"","context":"In &quot;Business&quot;","block_context":{"text":"Business","link":"https:\/\/www.danieledavi.com\/blog\/category\/business\/"},"img":{"alt_text":"Toxic Waste","src":"https:\/\/i0.wp.com\/www.danieledavi.com\/blog\/wp-content\/uploads\/2021\/03\/Toxic_waste.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.danieledavi.com\/blog\/wp-content\/uploads\/2021\/03\/Toxic_waste.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.danieledavi.com\/blog\/wp-content\/uploads\/2021\/03\/Toxic_waste.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]}],"amp_validity":null,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.danieledavi.com\/blog\/wp-json\/wp\/v2\/posts\/308"}],"collection":[{"href":"https:\/\/www.danieledavi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.danieledavi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.danieledavi.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.danieledavi.com\/blog\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":2,"href":"https:\/\/www.danieledavi.com\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":311,"href":"https:\/\/www.danieledavi.com\/blog\/wp-json\/wp\/v2\/posts\/308\/revisions\/311"}],"wp:attachment":[{"href":"https:\/\/www.danieledavi.com\/blog\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.danieledavi.com\/blog\/wp-json\/wp\/v2\/categories?post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.danieledavi.com\/blog\/wp-json\/wp\/v2\/tags?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}