Skip to content

Instantly share code, notes, and snippets.

@tdhop
tdhop / OpenNSManagedDoc
Last active December 24, 2015 06:19
Open and initialize core data database that has been delivered with the app bundle. Note that text surrounded by <> will need to be replaced with local names for your app.
// Copy <Database> to runtime location in Documents directory and open data store.
- (void) init<Database>
{
/* Get URL of Documents directory. It returns all matching
directories in the domain but should only see one and it
is in location 0 of the array (or "lastObject")
*/
NSArray *tempURLs = [[NSFileManager defaultManager] URLsForDirectory: NSDocumentDirectory inDomains:NSUserDomainMask];
NSURL *documentsURL = [tempURLs lastObject];
@tdhop
tdhop / gist:5846707
Last active March 28, 2017 13:22
Simple method for creating expanding UITableView rows that expand in an animated fashion when accessory button is tapped. What you do with the extra space in the expanded row is up to you.
- (void) tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Detail Disclosure Tapped");
// Set expanded cell then tell tableView to redraw with animation
self.expandedRow = indexPath;
[self.tableView beginUpdates];
[self.tableView endUpdates];
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {