Finding Next Available Name in Objective-C
Useful method for finding the next available unique name in a batch of strings.
Eg: give it A list of { “Name”, “Name 1″, “Name 2″ } and it will return “Name 3″.
Useful method for finding the next available unique name in a batch of strings.
Eg: give it A list of { “Name”, “Name 1″, “Name 2″ } and it will return “Name 3″.
To format list of categories, ingredients etc in a more readable way for ChickenPing, I use a function which joins a list of strings using a separator and a final separator. Eg:
NSArray *items = [[NSArray alloc] initWithObjects:@"Item1", @"Item2", @"Item3", nil]; NSString *joined = [Utils implode:items withSeperator:@", " trimStrings:true lastSeparator:@" and "]; // returns "Item1, Item2 and Item3"
It’s more flexible than NSArraycomponentsJoinedByString: because it includes an optional last separator and the option to trim strings. Code is below.
I recently needed to create a table view where the user could scroll to the bottom to load more data, similar to Facebook’s ‘pull to refresh’. This shows a loading indicator while more data is retrieved. To do this I used a delegate which is implemented by a custom table view cell.
Read more »
For the last day, I’ve been on the brink of pulling my hair out trying to fix a bizarre error when trying to deploy an app to my iPhone. Everything worked fine in the simulator, but when I tried to deploy it to the device, I kept getting “The entitlements specified in your application’s Code Signing Entitlements file do not match those specified in your provisioning profile.”