{"id":6220,"date":"2012-11-01T09:17:46","date_gmt":"2012-11-01T03:47:46","guid":{"rendered":"https:\/\/www.indianic.com\/blog\/?p=6220"},"modified":"2021-02-08T18:38:05","modified_gmt":"2021-02-08T13:08:05","slug":"ios-development-use-of-tilde-sign-in-file-name","status":"publish","type":"post","link":"https:\/\/indianic.devpress.net\/blog\/mobile\/ios-development-use-of-tilde-sign-in-file-name.html","title":{"rendered":"iOS Development \u2013 Use of Tilde Sign (~) in File Name"},"content":{"rendered":"<p>Apple iOS development is a relatively new field of development, and there are a number of tips and tricks that developers can use to create better apps in lesser time. In this blogpost, I will talk about how to use the tilde (~) sign in a way that reduces your coding work.<\/p>\n<figure id=\"attachment_6226\" aria-describedby=\"caption-attachment-6226\" style=\"width: 609px\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\" wp-image-6226 \" title=\"Use of Tilde Sign in iOS programming for faster coding\" src=\"https:\/\/www.indianic.com\/blog\/wp-content\/uploads\/2012\/11\/Screen-Shot-2012-11-01-at-3.20.19-PM-1024x552.png\" alt=\"Use of Tilde Sign in iOS programming for faster coding\" width=\"609\" height=\"328\" \/><figcaption id=\"caption-attachment-6226\" class=\"wp-caption-text\">Use of Tilde Sign in iOS programming for faster coding<\/figcaption><\/figure>\n<p>While creating universal app for the iPhone and iPad, writing conditional code can take up a lot of time and energy. Thankfully, there is a simpler way in which you can achieve the same results. By giving file names with a tilde (~) sign, you can save your development efforts with ease.<\/p>\n<p><strong>Just use:<\/strong><\/p>\n<p>MyCtrlVC~iphone.XIB and MyCtrlVC~ipad.XIB<\/p>\n<p>Let\u2019s dig into the details. While developing universal apps, we have to write a conditional code for each device \u2013 the iPad as well as the iPhone. In this scenario, the proper use of tilde can be extremely beneficial.<\/p>\n<p>For example, if you want to push new view controller, then you\u2019d have to write lot of lines (almost 10) of code:<\/p>\n<p>if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)<\/p>\n<p>{<\/p>\n<p>MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@&#8221;MasterViewController_iphone&#8221; bundle:nil];<\/p>\n[self.navigationController pushViewController:masterViewController animated:YES];<\/p>\n[masterViewController release];<\/p>\n<p>}<\/p>\n<p>else<\/p>\n<p>{<\/p>\n<p>MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@&#8221;MasterViewController_ipad&#8221; bundle:nil];<\/p>\n[self.navigationController pushViewController:masterViewController animated:YES];<\/p>\n[masterViewController release];<\/p>\n<p>}<\/p>\n<p><strong>But here, the magical (~) will help you. You just have to give XIB name with tilde instead of underscore:<\/strong><\/p>\n<p>MasterViewController~iphone.XIB\u00a0 and MasterViewController~ipad.XIB<\/p>\n<p>Now you\u2019ll have to write only a few lines of code: Only 4 lines<\/p>\n<p>MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@&#8221;MasterViewController&#8221; bundle:nil];<\/p>\n[self.navigationController pushViewController:masterViewController animated:YES];<\/p>\n[masterViewController release];<\/p>\n<p>&nbsp;<\/p>\n<p>Isn\u2019t that amazing? A single tilde will help you save a lot of time and effort. It\u2019s almost magical. Start using it in your projects from now onwards! The best part is that this trick works for all kinds of files that were added in the source code, including image files like .png and .jpeg.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apple iOS development is a relatively new field of development, and there are a number of tips and tricks that developers can use to create better apps in lesser time. In this blogpost, I will talk about how to use the tilde (~) sign in a way that reduces your coding work. While creating universal&#8230;<\/p>\n","protected":false},"author":1,"featured_media":6226,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false},"categories":[277],"tags":[],"acf":{"show_table_of_content":null,"table_of_content":null},"_links":{"self":[{"href":"https:\/\/indianic.devpress.net\/blog\/wp-json\/wp\/v2\/posts\/6220"}],"collection":[{"href":"https:\/\/indianic.devpress.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/indianic.devpress.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/indianic.devpress.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/indianic.devpress.net\/blog\/wp-json\/wp\/v2\/comments?post=6220"}],"version-history":[{"count":0,"href":"https:\/\/indianic.devpress.net\/blog\/wp-json\/wp\/v2\/posts\/6220\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/indianic.devpress.net\/blog\/wp-json\/wp\/v2\/media\/6226"}],"wp:attachment":[{"href":"https:\/\/indianic.devpress.net\/blog\/wp-json\/wp\/v2\/media?parent=6220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/indianic.devpress.net\/blog\/wp-json\/wp\/v2\/categories?post=6220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/indianic.devpress.net\/blog\/wp-json\/wp\/v2\/tags?post=6220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}