[Solved] What is the best way to convert an array with NSStrings to NSDecimalNumber?

A very simple Category on NSArray will allow you to use map as seen in other languages @interface NSArray (Functional) -(NSArray *)map:(id (^) (id element))mapBlock; @end @implementation NSArray (Functional) -(NSArray *)map:(id (^)(id))mapBlock { NSMutableArray *array = [@[] mutableCopy]; for (id element in self) { [array addObject:mapBlock(element)]; } return [array copy]; } @end Now you can … Read more

[Solved] Sort strings alphabetically AND by length?

tl;dr: the key paths you are looking for are “length” and “self” (or “description” or “uppercaseString” depending on what how you want to compare) As you can see in the documentation for NSSSortDescriptor, a sort descriptor is created “by specifying the key path of the property to be compared”. When sorting string by their length, … Read more

[Solved] Swift Array append not appending values but replacing it

There is not enough information but I can guess you where you have made mistake. Your class Bookmark is not singleton class so,every time Bookmark() create new instance every time. that means it will create new bookmark object for every instance. What I suggest you is inside func func setBookmark(imageURL:String, title:String, description:String, summary:String, date:String, link:String) … Read more

[Solved] Checking whether elements of an Array contains a specified String

NSString has a rangeOfString function that can be used for looking up partial string matches. This function returns NSRange. You can use the location property. … NSArray *qwer = [NSArray arrayWithObjects:@”Apple Juice”,@”Apple cake”,@”Apple chips”,@”Apple wassail”nil]; for (NSString *name in qwer){ if ([name rangeOfString:keyword].location == NSNotFound) { NSLog(@”contains”); } } … Reference : https://developer.apple.com/reference/foundation/nsstring/1416849-rangeofstring https://developer.apple.com/reference/foundation/nsrange Thanks … Read more