Skip to content

Instantly share code, notes, and snippets.

View comiclandapp's full-sized avatar
💭
Vaporizing ComicLand

Antonio Montes comiclandapp

💭
Vaporizing ComicLand
View GitHub Profile
@comiclandapp
comiclandapp / README.md
Created November 4, 2024 01:47 — forked from davbeck/README.md
A wrapper for UICollectionViewDiffableDataSource that also handles updates to data

UICollectionViewDiffableDataSource does an excellent job of handling changes to data and updating the items accordingly. However, there seems to be no good way to handle updates to existing items. If you follow the samples that Apple provides and define Equatable and Hashable to use an id instead of the complete models value, value changes won't cause the collection view to update those cells. If you leave Equatable as it should be and have it compare all values of a model, the cell will update, but it will completely replace the old cell, causing an undesirable "flash".

UICollectionViewComparableDataSource wraps a UICollectionViewDiffableDataSource and will check for items that have been updated, but not removed or added.

This allows us to make updates to a cell without completely reloading it. This is especially usefull if your cells have some sort of temporary state.

This is just an expirement. Use at your own risk.

@comiclandapp
comiclandapp / StickyLayout.swift
Created May 10, 2022 00:27 — forked from ilyapuchka/StickyLayout.swift
Really sticky collection view layout
// The issue with sectionHeadersPinToVisibleBounds and sectionFootersPinToVisibleBounds is that they do not pin
// first header and last footer when bouncing. This layout subclass fixes that.
class StickyLayout: UICollectionViewFlowLayout {
override init() {
super.init()
self.sectionFootersPinToVisibleBounds = true
self.sectionHeadersPinToVisibleBounds = true
}
@comiclandapp
comiclandapp / RKAppDelegate.m
Created October 22, 2018 14:22 — forked from chourobin/RKAppDelegate.m
Setting up magical record with RestKit
#import <RestKit/RestKit.h>
#import "CoreData+MagicalRecord.h"
// Use a class extension to expose access to MagicalRecord's private setter methods
@interface NSManagedObjectContext ()
+ (void)MR_setRootSavingContext:(NSManagedObjectContext *)context;
+ (void)MR_setDefaultContext:(NSManagedObjectContext *)moc;
@end
@implementation AppDelegate
@comiclandapp
comiclandapp / !README.md
Created June 8, 2018 20:10 — forked from mayoff/!README.md
Debugging Objective-C blocks in lldb

The attached lldb command pblock command lets you peek inside an Objective-C block. It tries to tell you where to find the source code for the block, and the values captured by the block when it was created.

Consider this example program:

#import <Foundation/Foundation.h>

@interface Foo: NSObject
@end

@implementation Foo

@comiclandapp
comiclandapp / CoreDataController.h
Created April 9, 2018 00:55 — forked from kharrison/CoreDataController.h
Objective-C wrapper for NSPersistentContainer - Easy Core Data setup with iOS 10
//
// CoreDataController.h
//
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2016 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright
@comiclandapp
comiclandapp / CoreDataController.swift
Created April 7, 2018 13:52 — forked from kharrison/CoreDataController.swift
Swift wrapper for NSPersistentContainer - Easy Core Data Setup with iOS 10
//
// CoreDataController.swift
//
// Created by Keith Harrison http://useyourloaf.com
// Copyright (c) 2017 Keith Harrison. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright
@comiclandapp
comiclandapp / remove_stop_words.py
Created April 18, 2017 21:08 — forked from glenbot/remove_stop_words.py
Test various ways of removing stop words in python.
"""
Demonstration of ways to implement this API:
sanitize(user_input, stop_words)
Related discussions:
- Modifying a list while looping over it:
- http://stackoverflow.com/questions/1207406/remove-items-from-a-list-while-iterating-in-python
- Remove all occurences of a value in a list:
- http://stackoverflow.com/questions/1157106/remove-all-occurences-of-a-value-from-a-python-list