{"id":274,"date":"2011-05-27T08:03:54","date_gmt":"2011-05-27T08:03:54","guid":{"rendered":"https:\/\/blog.alwawee.ru\/?p=274"},"modified":"2011-07-06T13:13:15","modified_gmt":"2011-07-06T13:13:15","slug":"string-manipulation-in-iphone-applications","status":"publish","type":"post","link":"https:\/\/blog.alwawee.ru\/?p=274","title":{"rendered":"String manipulation in iPhone applications"},"content":{"rendered":"<p>These <strong>examples of string manipulation in iPhone apps<\/strong> were taken from the Internet and I don&#8217; pretend on the authority rights for them. <\/p>\n<ol>\n<li><strong>Appending string to another string:<\/strong><br \/>\n<code><br \/>\nNSString *myString = @\"This\";<br \/>\nNSString *test = [myString stringByAppendingString:@\" is just a test\"];<br \/>\n<\/code>\n<\/li>\n<p><\/br><\/p>\n<li><strong>Method with wide possibilities to format string and concatenate several strings:<\/strong><br \/>\n<code><br \/>\n- (NSString*) concatenateString:(NSString*)stringA withString:(NSString*)stringB {<br \/>\nNSString *finalString = [NSString stringWithFormat:@\"%@%@\", stringA, stringB]; return finalString; }<br \/>\n<\/code><br \/>\n<\/br><br \/>\nThe advantage of this method is that it is simple to put text between the two strings (e.g. Put a &#8220;-&#8221; replace %@%@ by %@ &#8211; %@ and that will put a dash between stringA and stringB\n<\/li>\n<p><\/br><\/p>\n<li><strong>String Length:<\/strong><br \/>\n<code><br \/>\n- (int) stringLength:(NSString*)string { return [string length]; \/\/Not sure for east-asian languages, but works fine usually }<br \/>\n<\/code><\/li>\n<p><\/br><\/p>\n<li><strong>Remove text from string:<\/strong><br \/>\n<code><br \/>\n- (NSString*)remove:(NSString*)textToRemove fromString:(NSString*)input { return [input stringByReplacingOccurrencesOfString:textToRemove withString:@\"\"]; }<br \/>\n<\/code><\/li>\n<p><\/br><\/p>\n<li><strong>Uppercase \/ Lowercase \/ Titlecase:<\/strong><br \/>\n<code><br \/>\n- (NSString*)uppercase:(NSString*)stringToUppercase { return [stringToUppercase upercaseString]; }<\/p>\n<p>- (NSString*)lowercase:(NSString*)stringToLowercase { return [stringToUppercase lowercaseString]; }<br \/>\n<\/code><\/li>\n<p><\/br><\/p>\n<li><strong>Find\/Replace:<\/strong><br \/>\n<code><br \/>\n- (NSString*)findInString:(NSString*)string replaceWithString:(NSString*)stringToReplaceWith { return [input stringByReplacingOccurrencesOfString:string withString:stringToReplaceWith]; }<br \/>\n<\/code>\n<\/li>\n<p><\/br><\/p>\n<li><strong>String comparison Case Sensitive<\/strong>:<br \/>\n<code><br \/>\nif ([category isEqualToString:@\"Some String\"])<br \/>\n{<br \/>\n   doSomething = YES;<br \/>\n}<br \/>\n<\/code><br \/>\n<\/br><br \/>\n<strong>Case Insensitive: <\/strong><br \/>\n<code><br \/>\nif (!([category compare:@\"Some String\" options:NSCaseInsensitiveSearch]))<br \/>\n{<br \/>\n   doSomething = YES;<br \/>\n}<br \/>\n<\/code>\n<\/li>\n<\/ol>\n<p><\/br><br \/>\n<strong>References: <\/strong><\/p>\n<ol>\n<li><a href=\"http:\/\/stackoverflow.com\/questions\/1778227\/string-manipulation-in-objective-c\">http:\/\/stackoverflow.com\/questions\/1778227\/string-manipulation-in-objective-c<\/a><\/li>\n<li><a href=\"http:\/\/www.techotopia.com\/index.php\/Working_with_String_Objects_in_Objective-C\">http:\/\/www.techotopia.com\/index.php\/Working_with_String_Objects_in_Objective-C<\/a> &#8211; The best reference on this topic\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>These examples of string manipulation in iPhone apps were taken from the Internet and I don&#8217; pretend on the authority rights for them. Appending string to another string: NSString *myString = @&#8221;This&#8221;; NSString *test = [myString stringByAppendingString:@&#8221; is just a test&#8221;]; Method with wide possibilities to format string and concatenate several strings: &#8211; (NSString*) concatenateString:(NSString*)stringA [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[],"class_list":["post-274","post","type-post","status-publish","format-standard","hentry","category-android"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>String manipulation in iPhone applications - Denis Kutlubaev<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/blog.alwawee.ru\/?p=274\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"String manipulation in iPhone applications - Denis Kutlubaev\" \/>\n<meta property=\"og:description\" content=\"These examples of string manipulation in iPhone apps were taken from the Internet and I don&#8217; pretend on the authority rights for them. Appending string to another string: NSString *myString = @&quot;This&quot;; NSString *test = [myString stringByAppendingString:@&quot; is just a test&quot;]; Method with wide possibilities to format string and concatenate several strings: - (NSString*) concatenateString:(NSString*)stringA [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog.alwawee.ru\/?p=274\" \/>\n<meta property=\"og:site_name\" content=\"Denis Kutlubaev\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/alwaweemobile\" \/>\n<meta property=\"article:published_time\" content=\"2011-05-27T08:03:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2011-07-06T13:13:15+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/blog.alwawee.com\/?attachment_id=1982\" \/>\n<meta name=\"author\" content=\"Denis Kutlubaev\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Denis Kutlubaev\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=274#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=274\"},\"author\":{\"name\":\"Denis Kutlubaev\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#\\\/schema\\\/person\\\/58f1f1f57155b48afab83ba53b3e26a7\"},\"headline\":\"String manipulation in iPhone applications\",\"datePublished\":\"2011-05-27T08:03:54+00:00\",\"dateModified\":\"2011-07-06T13:13:15+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=274\"},\"wordCount\":121,\"commentCount\":0,\"articleSection\":[\"Android\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/blog.alwawee.ru\\\/?p=274#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=274\",\"url\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=274\",\"name\":\"String manipulation in iPhone applications - Denis Kutlubaev\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#website\"},\"datePublished\":\"2011-05-27T08:03:54+00:00\",\"dateModified\":\"2011-07-06T13:13:15+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#\\\/schema\\\/person\\\/58f1f1f57155b48afab83ba53b3e26a7\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=274#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/blog.alwawee.ru\\\/?p=274\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/?p=274#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/blog.alwawee.ru\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"String manipulation in iPhone applications\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#website\",\"url\":\"https:\\\/\\\/blog.alwawee.ru\\\/\",\"name\":\"Denis Kutlubaev\",\"description\":\"iOS Development\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/blog.alwawee.ru\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/blog.alwawee.ru\\\/#\\\/schema\\\/person\\\/58f1f1f57155b48afab83ba53b3e26a7\",\"name\":\"Denis Kutlubaev\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg\",\"caption\":\"Denis Kutlubaev\"},\"description\":\"iOS Developer, creator of Tornado Browser and many other popular apps\",\"sameAs\":[\"http:\\\/\\\/dennis.alwawee.com\"],\"url\":\"https:\\\/\\\/blog.alwawee.ru\\\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"String manipulation in iPhone applications - Denis Kutlubaev","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/blog.alwawee.ru\/?p=274","og_locale":"en_US","og_type":"article","og_title":"String manipulation in iPhone applications - Denis Kutlubaev","og_description":"These examples of string manipulation in iPhone apps were taken from the Internet and I don&#8217; pretend on the authority rights for them. Appending string to another string: NSString *myString = @\"This\"; NSString *test = [myString stringByAppendingString:@\" is just a test\"]; Method with wide possibilities to format string and concatenate several strings: - (NSString*) concatenateString:(NSString*)stringA [&hellip;]","og_url":"https:\/\/blog.alwawee.ru\/?p=274","og_site_name":"Denis Kutlubaev","article_publisher":"https:\/\/www.facebook.com\/alwaweemobile","article_published_time":"2011-05-27T08:03:54+00:00","article_modified_time":"2011-07-06T13:13:15+00:00","og_image":[{"url":"http:\/\/blog.alwawee.com\/?attachment_id=1982","type":"","width":"","height":""}],"author":"Denis Kutlubaev","twitter_misc":{"Written by":"Denis Kutlubaev","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/blog.alwawee.ru\/?p=274#article","isPartOf":{"@id":"https:\/\/blog.alwawee.ru\/?p=274"},"author":{"name":"Denis Kutlubaev","@id":"https:\/\/blog.alwawee.ru\/#\/schema\/person\/58f1f1f57155b48afab83ba53b3e26a7"},"headline":"String manipulation in iPhone applications","datePublished":"2011-05-27T08:03:54+00:00","dateModified":"2011-07-06T13:13:15+00:00","mainEntityOfPage":{"@id":"https:\/\/blog.alwawee.ru\/?p=274"},"wordCount":121,"commentCount":0,"articleSection":["Android"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/blog.alwawee.ru\/?p=274#respond"]}]},{"@type":"WebPage","@id":"https:\/\/blog.alwawee.ru\/?p=274","url":"https:\/\/blog.alwawee.ru\/?p=274","name":"String manipulation in iPhone applications - Denis Kutlubaev","isPartOf":{"@id":"https:\/\/blog.alwawee.ru\/#website"},"datePublished":"2011-05-27T08:03:54+00:00","dateModified":"2011-07-06T13:13:15+00:00","author":{"@id":"https:\/\/blog.alwawee.ru\/#\/schema\/person\/58f1f1f57155b48afab83ba53b3e26a7"},"breadcrumb":{"@id":"https:\/\/blog.alwawee.ru\/?p=274#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog.alwawee.ru\/?p=274"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog.alwawee.ru\/?p=274#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog.alwawee.ru\/"},{"@type":"ListItem","position":2,"name":"String manipulation in iPhone applications"}]},{"@type":"WebSite","@id":"https:\/\/blog.alwawee.ru\/#website","url":"https:\/\/blog.alwawee.ru\/","name":"Denis Kutlubaev","description":"iOS Development","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog.alwawee.ru\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/blog.alwawee.ru\/#\/schema\/person\/58f1f1f57155b48afab83ba53b3e26a7","name":"Denis Kutlubaev","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg","url":"https:\/\/secure.gravatar.com\/avatar\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/346de75d27c818be0aa7fddeada2e50e30cc15b4da6b3b8110c5d766cd2afa34?s=96&d=mm&r=pg","caption":"Denis Kutlubaev"},"description":"iOS Developer, creator of Tornado Browser and many other popular apps","sameAs":["http:\/\/dennis.alwawee.com"],"url":"https:\/\/blog.alwawee.ru\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/posts\/274","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=274"}],"version-history":[{"count":0,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=\/wp\/v2\/posts\/274\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.alwawee.ru\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}