{"id":5853,"date":"2014-04-07T09:39:32","date_gmt":"2014-04-07T09:39:32","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/04\/07\/objective-c-function-help-collection-of-common-programming-errors\/"},"modified":"2014-04-07T09:39:32","modified_gmt":"2014-04-07T09:39:32","slug":"objective-c-function-help-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/04\/07\/objective-c-function-help-collection-of-common-programming-errors\/","title":{"rendered":"Objective C: Function help-Collection of common programming errors"},"content":{"rendered":"<p>Greetings,<\/p>\n<p>I have the following function:<\/p>\n<pre><code>-(NSString*) nudgePhoneNumber:(NSString*)num{\n    NSString *nudged=@\"\";\n    [nudged stringByReplacingOccurrencesOfString:@\"+\" withString:@\"\"];\n    [nudged stringByReplacingOccurrencesOfString:@\"\\\\s\" withString:@\"\"];\n    [nudged stringByReplacingOccurrencesOfString:@\"-\" withString:@\"\"];\n    [nudged stringByReplacingOccurrencesOfString:@\".\" withString:@\"\"];\n    [nudged stringByReplacingOccurrencesOfString:@\"\/\" withString:@\"\"];\n    \/\/NSLog(nudged);\n    return nudged;\n}\n<\/code><\/pre>\n<p>And I&#8217;m calling it as follows:<\/p>\n<pre><code>-(IBAction) phoneNumberUp:(id)sender{\n    NSString *mob=phoneNumber.text;\n    NSString *result=@\"\";\n    [result nudgePhoneNumber:mob];\n        ...\n}\n<\/code><\/pre>\n<p>But I keep getting an exception: &#8220;-[NSCFException nudgePhoneNumber:]: unrecognized selector sent to instance&#8221; and &#8220;Terminating app due to uncaught exception &#8216;NSInvalidArgumentException'&#8221;<\/p>\n<p>I&#8217;m quite new to Objective-C and think I just need someone to have a quick look-over.<\/p>\n<p>Many thanks in advance,<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Greetings, I have the following function: -(NSString*) nudgePhoneNumber:(NSString*)num{ NSString *nudged=@&#8221;&#8221;; [nudged stringByReplacingOccurrencesOfString:@&#8221;+&#8221; withString:@&#8221;&#8221;]; [nudged stringByReplacingOccurrencesOfString:@&#8221;\\\\s&#8221; withString:@&#8221;&#8221;]; [nudged stringByReplacingOccurrencesOfString:@&#8221;-&#8221; withString:@&#8221;&#8221;]; [nudged stringByReplacingOccurrencesOfString:@&#8221;.&#8221; withString:@&#8221;&#8221;]; [nudged stringByReplacingOccurrencesOfString:@&#8221;\/&#8221; withString:@&#8221;&#8221;]; \/\/NSLog(nudged); return nudged; } And I&#8217;m calling it as follows: -(IBAction) phoneNumberUp:(id)sender{ NSString *mob=phoneNumber.text; NSString *result=@&#8221;&#8221;; [result nudgePhoneNumber:mob]; &#8230; } But I keep getting an exception: &#8220;-[NSCFException nudgePhoneNumber:]: unrecognized selector [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5853","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5853","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5853"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5853\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5853"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5853"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5853"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}