A data-driven UICollectionView framework for building fast and flexible lists.
Find a file
Maxime Ollivier 6ea2b91150 avoid crashing when not subclassing IGListSectionController
Summary:
Currently, if you use `IGListSectionController` without a subclass, `UICollectionView` will crash when requesting the cell. That's because `[IGListSectionController numberOfItems]` defaults to 1, but returns no cell. There's a few issues with that:
1. It can be tough to debug, because the crash in within `UICollectionView`. We don't know the dataSource or object type responsible.
2. The crash only happens if the user scrolls by the missing cell, which can make it hard to repro.
3. If we don't know how to render a single section, we might not want to crash the entire app. Passing a plain `IGListSectionController` kind of feels like the dataSource is ok with just rendering nothing. It's not clear at all that it will crash.

Options:
1. Crash immediately when a plain `IGListSectionController` is passed to `IGListAdapter`, so we get a clear callstack and API feedback. If the dataSource doesn't want to crash, it must return `IGEmptySectionController` that has 0 `numberOfItems`.
2. Don't crash, but log a `IGFailAssert()`. If the dataSource wants to throw on a missing object-controller match, they can can, but it's not the IGListKit default.

I'm leaning on #2 for a few reasons. It's really not obvious that passing a plain `IGListSectionController` would crash and no one will know that `IGEmptySectionController` exists. We could have a linter, but that only works within Meta.

Reviewed By: DimaVartanian

Differential Revision: D52087286

fbshipit-source-id: 8b8754d56e66c0c2b00f8df3b9671a6fc2287aea
2023-12-14 14:27:34 -08:00
.github Fix UI test timeout when running on GitHub Actions 2023-11-19 17:57:35 -08:00
docs Updated copyright symbol in documentation 2023-04-07 01:58:02 -07:00
Examples Harden iOS UI tests to catch potential infinite loops 2023-10-13 22:50:38 -07:00
Guides Improve SwiftPM support (#1546) 2023-03-06 23:29:41 -08:00
IGListKit.xcodeproj Update IGListKit Xcode project settings and version to Xcode 15 2023-10-13 22:50:38 -07:00
remodel-plugin Standarize the copyright notice in all source files 2023-04-06 02:44:16 -07:00
Resources Create binding and modeling guide/tutorial 2017-08-21 14:46:53 -07:00
scripts Fix SwiftLint script to execute in correct location via the sample apps 2023-10-13 22:50:38 -07:00
Source avoid crashing when not subclassing IGListSectionController 2023-12-14 14:27:34 -08:00
spm/Sources Add symlink for new IGListArrayUtilsInternal.m (#1591) 2023-10-11 21:26:45 -07:00
Tests avoid crashing when not subclassing IGListSectionController 2023-12-14 14:27:34 -08:00
.gitignore Improve SwiftPM support (#1546) 2023-03-06 23:29:41 -08:00
.slather.yml Omit the test suite from code coverage stats 2023-04-17 20:41:49 -07:00
.swiftlint.yml Updated and reintegrated Danger into GitHub Actions CI 2023-02-28 18:53:02 -08:00
CHANGELOG.md avoid crashing when not subclassing IGListSectionController 2023-12-14 14:27:34 -08:00
CODE_OF_CONDUCT.md Adopt Contributor Covenant 2019-08-29 23:20:54 -07:00
Dangerfile Updated and reintegrated Danger into GitHub Actions CI 2023-02-28 18:53:02 -08:00
Gemfile Update build pipeline to improve reliability 2023-11-13 09:50:13 -08:00
IGListDiffKit.podspec Update deployment targets to silence Xcode 14 warnings (#1573) 2023-05-01 22:48:23 -07:00
IGListKit.podspec Update deployment targets to silence Xcode 14 warnings (#1573) 2023-05-01 22:48:23 -07:00
IGListSwiftKit.podspec Update deployment targets to silence Xcode 14 warnings (#1573) 2023-05-01 22:48:23 -07:00
LICENSE.md Standarize the copyright notice in all source files 2023-04-06 02:44:16 -07:00
Package.swift Update deployment targets to silence Xcode 14 warnings (#1573) 2023-05-01 22:48:23 -07:00
Podfile Update deployment targets to silence Xcode 14 warnings (#1573) 2023-05-01 22:48:23 -07:00
README.md Update deployment targets to silence Xcode 14 warnings (#1573) 2023-05-01 22:48:23 -07:00
README.zh.md Update deployment targets to silence Xcode 14 warnings (#1573) 2023-05-01 22:48:23 -07:00

Build Status Coverage Status Pods Version Platforms Carthage Compatible


A data-driven UICollectionView framework for building fast and flexible lists.

Main Features
🙅 Never call performBatchUpdates(_:, completion:) or reloadData() again
🏠 Better architecture with reusable cells and components
🔠 Create collections with multiple data types
🔑 Decoupled diffing algorithm
Fully unit tested
🔍 Customize your diffing behavior for your models
📱 Simply UICollectionView at its core
🚀 Extendable API
🐦 Written in Objective-C with full Swift interop support

IGListKit is built and maintained with ❤️ by Instagram engineering. We use the open source version main branch in the Instagram app.

Multilingual translation

Chinese README

Requirements

  • Xcode 11.0+
  • iOS 11.0+
  • tvOS 11.0+
  • macOS 10.13+ (diffing algorithm components only)
  • Interoperability with Swift 3.0+

Installation

CocoaPods

The preferred installation method is with CocoaPods. Add the following to your Podfile:

pod 'IGListKit', '~> 4.0.0'

Carthage

For Carthage, add the following to your Cartfile:

github "Instagram/IGListKit" ~> 4.0.0

Swift Package Manager

For Swift Package Manager:

To integrate using Xcode:

File -> Swift Packages -> Add Package Dependency

Enter package URL: https://github.com/Instagram/IGListKit, and select the latest release.

For advanced usage, see our Installation Guide.

Getting Started

Try out IGListKit by opening any of the sample apps available in the Examples directory.

Documentation

You can find the docs here. Documentation is generated with jazzy and hosted on GitHub-Pages.

To regenerate docs, run ./scripts/build_docs.sh from the root directory in the repo.

Vision

For the long-term goals and "vision" of IGListKit, please read our Vision doc.

Contributing

Please see the CONTRIBUTING file for how to help. At Instagram, we sync the open source version of IGListKit daily, so we're always testing the latest changes. But that requires all changes be thoroughly tested and follow our style guide.

We have a set of starter tasks that are great for beginners to jump in on and start contributing.

License

IGListKit is MIT-licensed.

The files in the /Examples/ directory are licensed under a separate license as specified in each file. Documentation is licensed CC-BY-4.0.

Copyright © Meta Platforms, Inc • Terms of UsePrivacy Policy