• Stars
    star
    216
  • Rank 183,179 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 10 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An Objective-C and Swift collection for iOS and OS X that stores objects grouped into sections.

INTUGroupedArray

Build Status Test Coverage Version Platform License

An Objective-C and Swift collection for iOS and OS X that stores objects grouped into sections.

INTUGroupedArray is an Objective-C data structure that takes the common one-dimensional array to the next dimension. The grouped array is designed with a familiar API to fit right in alongside Foundation collections like NSArray, with fully-featured immutable and mutable variants. A thin bridge brings the grouped array to Swift as native classes, where it harnesses the power, safety, and flexibility of generics, optionals, subscripts, literals, tuples, and much more.

INTUGroupedArray is extremely versatile, and can replace complicated nested arrays or combinations of other data structures as a general purpose data storage mechanism. The grouped array is ideal to use as a UITableView data source, as it is highly compatible with the data source and delegate callbacks -- requiring only a single line of code in many cases. However, it is suitable for use across the entire stack of iOS and OS X applications.

Setup

Objective-C

Using CocoaPods

  1. Add the pod INTUGroupedArray to your Podfile.

    pod 'INTUGroupedArray'
    
  2. Run pod install from Terminal, then open your app's .xcworkspace file to launch Xcode.

  3. Import the umbrella header INTUGroupedArrayImports.h so that all the grouped array classes are available to use. Typically, this should be written as #import <INTUGroupedArray/INTUGroupedArrayImports.h>

Manually from GitHub

  1. Download the Objective-C source files in the Source/INTUGroupedArray directory.
  2. Add all the files to your Xcode project (drag and drop is easiest).
  3. Import the umbrella header INTUGroupedArrayImports.h so that all the grouped array classes are available to use.

Swift

  1. To use the grouped array in Swift, you first need to obtain the Objective-C source code and integrate it into your project (see above).
  2. Download the GroupedArray.swift Swift source file in the Source/Swift directory and add it to your project.
  3. If you haven't already, you will need to set up an Objective-C Bridging Header for your project.
  4. Add the umbrella header INTUGroupedArrayImports.h to your Bridging Header file. (The Swift grouped array classes depend on this so they can access the Objective-C source.)

At this point, the native Swift classes GroupedArray and MutableGroupedArray will be available to use in your project's Swift code.

Concept

At a high level, the grouped array is a collection of sections, each of which contains an array of objects. Both the sections and objects can be instances of any class.

INTUGroupedArray Illustration

The grouped array closely mirrors the structure of a UITableView, which also has rows organized into one or more sections. As a result, the table view data source and delegate methods map directly to grouped array API methods.

Some of the grouped array APIs are similar to those of a dictionary (e.g. retrieving the objects in a section by passing in the section itself, instead of its index). Note that, unlike a dictionary, the grouped array does not require elements (sections or objects) to implement a -hash method or require that elements have a stable hash value once inside a grouped array. However, this comes at the cost of performance for certain operations like section lookups.

Like the Foundation collections, there are two variants of the grouped array:

  • INTUGroupedArray: An immutable grouped array. Thread safe. (Swift type: GroupedArray)
  • INTUMutableGroupedArray: A mutable subclass. Not thread safe. (Swift type: MutableGroupedArray)

As a best practice, you should favor the static immutable grouped array over the dynamic mutable variant.

The performance of most operations is annotated in the detailed documentation above the implementation of each method in the .m file. (The documentation in the header files is abbreviated to provide a convenient API reference.)

Key Design Points

No empty sections

Every section in a grouped array must contain at least one object, similar to how every key in a dictionary must be associated with a value. This design simplifies some of the complexity when dealing with multi-dimensional data structures. For example, this allows a section to be removed as soon as its last object is removed. If there is a use case where you do want an 'empty' section, you can use a single placeholder object to achieve this.

Sections should be unique

The grouped array is designed under the assumption that no two sections in the grouped array are considered equal (using -isEqual:). For example, this allows sections to be automatically created and removed as needed in the mutable grouped array. Although it is discouraged, it is technically possible to have duplicate sections, however this impairs the functionality of section-based APIs (e.g. -indexOfSection:, -indexOfObject:inSection:, -addObject:toSection:, and others) which will only operate on one instance of the section.

Errors are handled gracefully

Most errors are not fatal errors, and there is a better way to recover than terminating the entire app. In Debug builds, the grouped array will throw exceptions on errors, however with assertions disabled in Release builds, it will not crash. For example, attempting to access a section at an out-of-bounds index will throw an exception in Debug, but will simply return nil in Release. In the Swift grouped array, this is communicated via implicitly unwrapped optionals -- these values will only be nil if there was an error, so you should test for nil if you wish to avoid runtime errors.

Usage

Here are some snippets of common operations with a grouped array. Note that this is only a small portion of the overall API -- refer to the source files for the full API and documentation.

Objective-C

Create an immutable grouped array using the literal syntax:

INTUGroupedArray *groupedArray = [INTUGroupedArray literal:@[@"Section 1", @[@"Object A", @"Object B"],
                                                             @"Section 2", @[@"Object C"],
                                                             @"Section 3", @[@"Object D", @"Object E", @"Object F"]]];

Count the number of sections and objects in the grouped array:

NSUInteger sectionCount = [groupedArray countAllSections];
NSUInteger objectCount = [groupedArray countAllObjects];

Access the first section:

id section = [groupedArray sectionAtIndex:0];

Get an array of objects in the first section:

NSArray *objectsInSection = [groupedArray objectsInSectionAtIndex:0];

Access the first object in the first section (using NSIndexPath):

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
id object = [groupedArray objectAtIndexPath:indexPath];	

Get an array of all objects:

NSArray *allObjects = [groupedArray allObjects];

Iterate over the objects in the grouped array:

for (id object in groupedArray) { /* do something with object */ }

Get a mutable copy of the immutable grouped array:

INTUMutableGroupedArray *mutableGroupedArray = [groupedArray mutableCopy];

Add an object to the end of the first section:

[mutableGroupedArray addObject:@"New Object" toSectionAtIndex:0];

Insert an object at the beginning of Section 3:

[mutableGroupedArray insertObject:@"Another Object" atIndex:0 inSection:@"Section 3"];

Remove the second section:

[mutableGroupedArray removeSectionAtIndex:1];

Test if two grouped arrays are equal (contain the same sections & objects):

if ([groupedArray isEqual:mutableGroupedArray]) { /* the two grouped arrays are equal */ }

Swift

Create an immutable grouped array (with both sections and objects of type NSString) using an array literal:

let groupedArray: GroupedArray<NSString, NSString> = ["Section 1", ["Object A", "Object B"],
                                                      "Section 2", ["Object C"],
                                                      "Section 3", ["Object D", "Object E", "Object F"]]

Count the number of sections and objects:

let sectionCount = groupedArray.countAllSections()
let objectCount = groupedArray.countAllObjects()

Access the first section using a subscript:

let section = groupedArray[0]

Access the first object in the second section using a subscript:

let object = groupedArray[1, 0]

Access an object by index path using a subscript:

let indexPath = NSIndexPath(forRow: 0, inSection: 0)
let object = groupedArray[indexPath]

Get the last object in the grouped array, if there is one:

if let lastObject = groupedArray.lastObject() { /* do something with lastObject */ }

Iterate over the grouped array:

for (section, object) in groupedArray { /* do something with the section/object */ }

Get a mutable copy of the immutable grouped array:

var mutableGroupedArray = groupedArray.mutableCopy() // the type of mutableGroupedArray is inferred to be: MutableGroupedArray<NSString, NSString>

Replace the first object in the third section using a subscript:

mutableGroupedArray[2, 0] = "Another Object"

Test if two grouped arrays are equal (contain the same sections & objects):

if (groupedArray == mutableGroupedArray) { /* the two grouped arrays are equal */ }

Sample Projects

There are two sample projects provided.

The Objective-C sample project demonstrates how the grouped array can be used to back a table view on iOS. This project requires Xcode 6.0 or higher.

The Swift sample project highlights some additional capabilities available when using the Swift interface. This project requires Xcode 6.1 or higher.

Unit Tests

The unit test suite is incorporated into the Objective-C sample project. It is cross platform, and can run on iOS and OS X.

Issues & Contributions

Please open an issue here on GitHub if you have a problem, suggestion, or other comment.

Pull requests are welcome and encouraged! There are no official guidelines, but please try to be consistent with the existing code style. Any contributions should include new or updated unit tests as necessary to maintain thorough test coverage.

License

INTUGroupedArray is provided under the MIT license.

INTU on GitHub

Check out more iOS and OS X open source projects from Intuit!

More Repositories

1

karate

Test Automation Made Simple
Java
5,080
star
2

LocationManager

Easily get the device's current location on iOS.
Objective-C
2,562
star
3

CardParts

A reactive, card-based UI framework built on UIKit for iOS developers.
Swift
2,521
star
4

auto

Generate releases based on semantic version labels on pull requests.
TypeScript
2,262
star
5

sdp

An Android lib that provides a new size unit - sdp (scalable dp). This size unit scales with the screen size.
2,256
star
6

wasabi

Wasabi A/B Testing service is an open source project that is no longer under active development or being supported
Java
1,134
star
7

AnimationEngine

Easily build advanced custom animations on iOS.
Objective-C
1,059
star
8

ssp

Variant of sdp project based on the sp size unit.
542
star
9

design-systems-cli

A CLI toolbox for creating design systems.
TypeScript
401
star
10

devtools-ds

UI components, libraries, and templates for building robust devtools experiences.
TypeScript
250
star
11

QuickBooks-V3-PHP-SDK

Official PHP SDK for QuickBooks REST API v3.0: https://developer.intuit.com/
PHP
242
star
12

fuzzy-matcher

A Java library to determine probability of objects being similar.
Java
232
star
13

katlas

A distributed graph-based platform to automatically collect, discover, explore and relate multi-cluster Kubernetes resources and metadata.
Go
209
star
14

superglue

Superglue is a lineage-tracking tool built to help visualize the propagation of data through complex pipelines composed of tables, jobs and reports.
Scala
155
star
15

truffle-shuffle

An Android data-driven, percentage-based UI Card Gallery Library
Kotlin
149
star
16

maven-build-scanner

Know your build - so you can make it faster
Java
148
star
17

benten

Chatbot Development Framework (with Slack integration for Jira and Jenkins)
Java
134
star
18

foremast

Foremast adds application resiliency to Kubernetes by leveraging machine learnt patterns of application health to keep applications healthy and stable
Java
131
star
19

oauth-jsclient

Intuit's NodeJS OAuth client provides a set of methods to make it easier to work with OAuth2.0 and Open ID
JavaScript
124
star
20

costBuddy

costBuddy will gather cost information from multiple AWS accounts and generate a nice Grafana dashboard with alerting in place.
Python
112
star
21

QuickBooks-V3-DotNET-SDK

.Net SDK for QuickBooks REST API v3 services
C#
107
star
22

Trapheus

This tool automates restoration of RDS database instances from snapshots into any dev, staging or production environments. It supports individual RDS Snapshot as well as cluster snapshot restore operations.
Python
106
star
23

Ignite

Modern markdown documentation generator
JavaScript
103
star
24

accessibility-snippets

VSCode Snippets created to help developers write accessible code.
JavaScript
102
star
25

fawkes

πŸš€πŸš€ Fetch, parse, categorize, summarize user reviews πŸš€πŸš€
Python
92
star
26

proof

A tapable integration testing library for your Storybook stories
TypeScript
86
star
27

Tank

Tank is a downloadable application that can be used to load test websites
Java
84
star
28

aws_account_utils

Deprecated - Utility to help create and modify your AWS account
Ruby
81
star
29

graphql-filter-java

This project is developed to help developers add filtering support to their graphql-java services
Java
70
star
30

oauth-pythonclient

The Python OAuth client provides a set of methods that make it easier to work with Intuit's OAuth and OpenID Connect implementation.
Python
70
star
31

automation-for-humans

Converts English statements to automation.
Python
67
star
32

QuickBooks-V3-Java-SDK

Java SDK for QuickBooks REST API v3 services
Java
66
star
33

simple_deploy

Maintenance Mode - Simple Deploy is an opinionated CLI tool for managing AWS Cloud Formation Stacks.
Ruby
64
star
34

postcss-themed

A PostCSS plugin for generating themes.
TypeScript
62
star
35

autometer

Distributed load testing made simple
Shell
57
star
36

commently

πŸ˜€πŸ’¬ Easily comment and update comments on GitHub PRs
TypeScript
57
star
37

AnimatedFormFieldTableViewCell

UITextField for iOS that enables the user to see both the Input Text and the Placeholder
Swift
56
star
38

AutoRemoveObserver

iOS Auto-removing NSNotifications
Objective-C
53
star
39

judo

Judo is an easy-to-use Command Line Interface (CLI) Integration Testing Framework, driven from a simple yaml file that also contains assertions.
JavaScript
51
star
40

Traverser

Traverser is a Java library that helps software engineers implement advanced iteration of a data structure.
Java
49
star
41

react-json-reconciler

This project leverages the react-reconciler to allow users to serialize JSX trees into JSON objects.
TypeScript
48
star
42

intuit-developer-nodejs

A starting point for anyone looking to quickly jump onto the Intuit Developer Platform, Intuit-developer-nodejs ties together OAuth, OpenID, NodeJS, QuickBooks APIs and SDK.
JavaScript
46
star
43

DockDockBuild

Support for running UNIX Makefiles on a Docker container
Kotlin
45
star
44

bias-detector

Python
44
star
45

xhr-xdr-adapter

Enables (to the extent possible) support for Cross Origin Resource Sharing (CORS) on IE versions 8 and 9
JavaScript
41
star
46

user-data-for-fraud-prevention

Simple npm package with a utility to collect data from the browser required for compliance with fraud prevention APIs.
TypeScript
40
star
47

hooks

Hooks is a little module for plugins, in Kotlin
Kotlin
39
star
48

ami-query

Provide a REST interface to your organization's AMIs
Go
39
star
49

qb-animation-library

CSS and SCSS for adding QuickBooks animation to your project.
CSS
38
star
50

cyphfell

Converts WDIO to Cypress
JavaScript
34
star
51

sac3

Official repo for SAC3: Reliable Hallucination Detection in Black-Box Language Models via Semantic-aware Cross-check Consistency
Jupyter Notebook
33
star
52

storybook-addon-sketch

A Storybook add-on to get the contents of the current story as a Sketch file
TypeScript
31
star
53

CloudRaider

A resiliency tool that automates Failure mode effect analysis tests, simplifying complex testing with a behavior-driven development and testing approach. Provides a programmatic way to execute controlled failures in AWS and a BDD way to write test cases, allowing test plans themselves to become test cases that can be executed as is.
Java
30
star
54

oauth-rubyclient

Ruby OAuth 2.0 client for QuickBooks Online
Ruby
29
star
55

saloon

An E2E test seeder for enterprise web applications
JavaScript
29
star
56

identity-authz-apl

Attribute-based access control (ABAC), also known as policy-based access control, defines an access control paradigm whereby access rights are granted to users through the use of policies which reason over data in attributes. The policies can use any type of attributes (user attributes, resource attributes, object, environment attributes etc.). Read more here - https://en.wikipedia.org/wiki/Attribute-based_access_control ABAC Policy Language is used by ABAC to author policies. A policy consists of rules, which have "when" conditions and "then" actions. Policies are executed in a bounded time, goaled to reach a decision as quickly as possible in deterministic, fast and reliable way. Further light-weight execution consumes minimal resources.
Java
28
star
57

Decision-Trees-over-FHE

Decision trees training and prediction over encrypted data using Fully Homomorphic Encryption
C++
26
star
58

QuickFabric

A one-stop shop for all management and monitoring of Amazon Elastic Map Reduce (EMR) clusters across different AWS accounts and purposes.
JavaScript
26
star
59

metriks

Python package of commonly used metrics for evaluating information retrieval models.
Python
25
star
60

intuit-spring-cloud-config-inspector

Inspection of Spring Cloud Config properties made easy using React
JavaScript
25
star
61

mlctl

mlctl is the control plane for MLOps. It provides a CLI and a Python SDK for supporting key operations related to MLOps, such as "model training", "model hosting" etc.
Python
25
star
62

RBHC

This project implements machine learning to accomplish recursive binary hierarchical clustering of data primarily useful for any clickstream data along with providing cluster statistics for each cluster and visualization using d3js
Python
25
star
63

eslint-plugin-no-explicit-type-exports

A plugin to guard against exporting imported types.
TypeScript
24
star
64

text-provider

A react component which provides all the string constants using provider pattern
JavaScript
24
star
65

istanbul-cobertura-badger

Create a Code Coverage badge for Node.js Apps running node-istanbul.
JavaScript
24
star
66

LD-React-Components

Semantic component helpers to support LaunchDarkly feature flags in your React app.
JavaScript
24
star
67

ts-readme

Generate docs from typescript and put it in a README
TypeScript
23
star
68

WeakForwarder

Objective-C NSProxy class for iOS and OS X to allow for real weak delegates.
Objective-C
23
star
69

doc-blocks

A design system for doc-blocks UI components, built on @design-systems/cli.
TypeScript
22
star
70

node-pom-parser

Parsing Java's pom.xml and properly returning the json object, including attributes and values.
TypeScript
22
star
71

PHP-Payments-SDK

QuickBooks Online Payments SDK
PHP
20
star
72

rego

A command-line batch interface to the RuleFit statistical model building program.
R
20
star
73

innersource-scanner

A java api and command line tool for scanning, reporting and fixing a git repository's InnerSource Readiness based on a supplied specification which defines the files and file contents necessary for a repository to be considered ready for InnerSource contribution.
Java
20
star
74

universal-graph-client

A Java library that provides single API and a CLI to connect to all varieties of graph databases.
Java
19
star
75

funnel

A Go library that provides unification of identical operations (e.g. API requests).
Go
18
star
76

gitdetect

A GitHub scanning tool to help you find misplaced secrets in your source code repository files
Go
17
star
77

foremast-brain

Foremast-brain is a component of Foremast project.
Jupyter Notebook
17
star
78

naavik

Go
16
star
79

ReplayWeb

ReplayWeb is a collection of tools to accelerate building and maintaining functional tests for user interfaces.
JavaScript
16
star
80

intuit-spring-cloud-config-validator

Validation tools for Spring Cloud Config repos: .json, .yam|, .yml and .properties, verified through script or GitHub Pre-receive Hook!
Python
16
star
81

cfn-deploy

A useful GitHub Action to help you deploy cloudformation templates
Shell
15
star
82

heirloom

Maintenance Mode - Build, deploy and manage archives and their metadata in S3 and SimpleDB.
Ruby
15
star
83

apollo-mock-http

An easy and maintainable way of injecting mock data into Apollo GraphQL Client for fast feature development decoupled from API/Backend.
JavaScript
14
star
84

semantic-release-slack

A plugin for semantic-release that takes a Slack web hook and posts a message when a release is successful
JavaScript
14
star
85

dse-pronto

Pronto is an automation suite for deploying and managing DataStax Cassandra clusters in AWS.
Shell
14
star
86

spring-pulsar

Spring client library for apache pulsar allows consuming applications to integrate easily with apache pulsar.
Kotlin
13
star
87

go-loadgen

go-loadgen is a log infrastructure testing tool. Also suitable for load testing big data pipelines
Go
13
star
88

standardly

Standardly allows you to check for compliance against standards. Once you code your standards into a 'rules' json object, you can scan a directory on your filesystem or a GitHub repo to check for its compliance against the standard.
JavaScript
13
star
89

graphql-orchestrator-java

GraphQL Orchestrator stitches the schemas from multiple micro-services and orchestrates the graphql queries to these services accurately at runtime
Groovy
12
star
90

scss-cleanup-scripts

Shell scripts for removing redundant Sass files, variables, mixins and deleting unused images
Shell
12
star
91

unmazedboot

🐳 Generic SpringBoot Docker files and image management πŸƒ
Dockerfile
12
star
92

spring-config-client-fallback

Spring Cloud Config Client with Fallback implementation for cases when the the config server is down
Java
11
star
93

Autumn

Micro-services injectable infrastructure project. Autumn enables rapid development of mico-service applications.
Java
11
star
94

sdbport

Maintenance Mode - Import / Export SimpleDB Domains.
Ruby
11
star
95

mastko

MasTKO is a security tool which detects DNS entries associated with AWS’s EC2 servers susceptible to takeover attack and attempts a takeover.
Python
10
star
96

lean-schema

Shrink your large GraphQL Schema to only what you need with Intuit LeanSchema!
Python
10
star
97

postgres-perfstats

Python
10
star
98

swift-hooks

A little module for plugins, in swift.
Swift
10
star
99

cfn-clone

CLI to clone cloud formation stacks
Go
10
star
100

thrive

Thrive is an ETL framework that runs single-row transformations on HDFS data and makes the data available in relational databases (Hive and Vertica).
Python
10
star