Ecno is a task state manager built on top of UserDefaults in pure Swift 4.

Overview

Build status Platform iOS Swift 5 compatible Carthage compatible CocoaPods compatible License: MIT

By Xmartlabs SRL.

Introduction

Ecno was inspired by Once Android library. It's a task state manager built on top of UserDefaults in pure Swift 4. This abstraction allows you to mark 'tasks' as done, 'to-do' and check for those states.

Ecno is ideal for:

  • Show tutorials once within the application.
  • Perform certain task periodically.
  • Trigger a task based on a user action.

Usage

First you need to initialize it:

Ecno.initialize()

Note: you should initialize it when your app gets launched.

Then, you can check whether a task was done by:

if !Ecno.beenDone("task") {
  //...
  Ecno.markDone("task")
}

Also, you can check for specific requirements about a certain task:

if Ecno.beenDone("task", scope: .appSession, numberOfTimes: .moreThan(3)) {
  // do stuff
}

or

if Ecno.beenDone("task", scope: .since(20.minutes), numberOfTimes: .lessThan(3)) {
  // do stuff
}

Additionally, you can program a 'to do' task by:

Ecno.toDo("show banner", scope: .until(3.hours), info: ["name": "bannerName"])

and then query if you need to do that task:

if Ecno.needToDo("show banner") {
  let info = Ecno.infoForToDo("show banner") // ["name": "bannerName"]
  // ...
}

Task

Any type conforming to the Task protocol. Since it would be the most common case, the String type already conforms to Task.

public protocol Task {

    var tag: String { get }

}

Scope

Scopes represents periods of time within the application.

  • .appInstall
    This period represents all times for the application.
  • .appVersion
    Period starting when the current version of the app was installed.
  • .appSession
    Period starting when the application was launched.
  • .since(TimeInterval)
    Period starting since TimeInterval time ago from now. For instance, .since(2.days)
  • .until(TimeInterval)
    Period valid until TimeInterval from now. For instance, .until(3.hours). This should be useful to set a 'to do' task that expires.

Functions

  • func toDo(_ task: Task, scope: Scope? = nil, info: [AnyHashable: Any]? = nil)
    Marks a task as 'to do' within a given scope, if it has already been marked as to do or been done within that scope then it will not be marked. If the scope is nil, then it will be marked as to do anyways.
  • func needToDo(_ task: Task) -> Bool
    Checks if a task is currently marked as 'to do'.
  • func infoForToDo(_ task: Task) -> [AnyHashable: Any]?
    Gets the info associated with a 'to do' task. (only if you provided it in the toDo(...) function)
  • func lastDone(_ task: Task) -> Date?
    Last done timestamp for a given task.
  • func beenDone(_ task: Task, scope: Scope = .appInstall, numberOfTimes: CountChecker = .moreThan(0)) -> Bool
    Checks if a task has been done with the given requirements.
  • func markDone(_ task: Task)
    Marks a task as done.

Requirements

  • iOS 8.0+
  • Swift 4.0+
  • Xcode 9.0+

Getting involved

  • If you want to contribute please feel free to submit pull requests.
  • If you have a feature request please open an issue.
  • If you found a bug or need help please check older issues

Before contribute check the CONTRIBUTING file for more info.

If you use Ecno in your app We would love to hear about it! Drop us a line on twitter.

Examples

Follow these 3 steps to run Example project:

  • Clone Ecno repository
  • Open Ecno workspace and run the Example project.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects.

To install Ecno, simply add the following line to your Podfile:

pod 'Ecno', '~> 3.0'

Carthage

Carthage is a simple, decentralized dependency manager for Cocoa.

To install Ecno, simply add the following line to your Cartfile:

github "xmartlabs/Ecno" ~> 3.0

Author

Change Log

This can be found in the CHANGELOG.md file.

You might also like...
Allows users to pull in new song releases from their favorite artists and provides users with important metrics like their top tracks, top artists, and recently played tracks, queryable by time range.

Spotify Radar Spotify Radar is an iOS application that allows users to pull in new song releases from their favorite artists and provides users with i

RippleQueries is an iOS application built as assessment task at Ripple Egypt. Built Using MVVM (Model-View-ViewModel) and Clean Architecture concepts
RippleQueries is an iOS application built as assessment task at Ripple Egypt. Built Using MVVM (Model-View-ViewModel) and Clean Architecture concepts

RippleRepositories RippleRepositories is an iOS application built as an assessment task at Ripple Egypt. Built Using RxSwift & MVVM (Model-View-ViewMo

Async State Machine aims to provide a way to structure an application thanks to state machines
Async State Machine aims to provide a way to structure an application thanks to state machines

Async State Machine Async State Machine aims to provide a way to structure an application thanks to state machines. The goal is to identify the states

SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller. Support 3D Touch!
SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller. Support 3D Touch!

SAHistoryNavigationViewController Support 3D Touch for iOS9!! SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationConto

DEVOTE In this SwiftUI tutorial, we will develop a task manager iOS application with Core Data integration.

DEVOTE In this SwiftUI tutorial, we will develop a task manager iOS application with Core Data integration. This is not a project with a boring user interface. This iOS and iPadOS application provides a personal touch and feel.

SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller. Support 3D Touch!
SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller. Support 3D Touch!

SAHistoryNavigationViewController realizes iOS task manager like UI in UINavigationContoller. Support 3D Touch!

Switch viewcontroller like ios task manager
Switch viewcontroller like ios task manager

Kaeru Kaeru can switch ViewController in NavigationController like iOS task manager UI (after iOS 9). Movie Usage You can use HistoryNavigationControl

A generic state manager compatible with Combine

Loadable A generic state manager Loadable is a simple state manager that helps you to better handle asynchronous operations How it works You can deliv

Pure SwiftUI state-driven library to present view sequences and hierarchies.
Pure SwiftUI state-driven library to present view sequences and hierarchies.

PathPresenter swiftUIOnboarding.mp4 Pure SwiftUI routing with transitions, animations, and .sheet() support. In SwiftUI, View is a function of the sta

 Zip - A Swift framework for zipping and unzipping files. Simple and quick to use. Built on top of minizip.
Zip - A Swift framework for zipping and unzipping files. Simple and quick to use. Built on top of minizip.

Zip A Swift framework for zipping and unzipping files. Simple and quick to use. Built on top of minizip. Usage Import Zip at the top of the Swift file

A swift network profiler built on top of URLSession.
A swift network profiler built on top of URLSession.

By Xmartlabs SRL. Introduction Xniffer is a non-intrusive framework for intercepting outgoing requests and their responses between your app and any ex

Pure makes Pure DI easy in Swift.

Pure Pure makes Pure DI easy in Swift. This repository also introduces a way to do Pure DI in a Swift application. Table of Contents Background Pure D

 Reactive extensions to Cocoa frameworks, built on top of ReactiveSwift.
Reactive extensions to Cocoa frameworks, built on top of ReactiveSwift.

ReactiveSwift offers composable, declarative and flexible primitives that are built around the grand concept of streams of values over time. These primitives can be used to uniformly represent common Cocoa and generic programming patterns that are fundamentally an act of observation.

iOS Simulator type agnostic snapshot testing, built on top of the FBSnapshotTestCase.
iOS Simulator type agnostic snapshot testing, built on top of the FBSnapshotTestCase.

SnappyTestCase iOS Simulator type agnostic snapshot testing, built on top of the FBSnapshotTestCase. Why? Snapshot testing helps to deliver views that

Forecast App is an ios application built on top of omdb movie api for batman lovers to see their favorite batman movies
Forecast App is an ios application built on top of omdb movie api for batman lovers to see their favorite batman movies

Catbon-Movie-App Forecast App is an ios application built on top of omdb movie api for batman lovers to see their favorite batman movies, users can al

 InsuranceCostsPrediction an example app built on top of SwiftUI
InsuranceCostsPrediction an example app built on top of SwiftUI

This is an example app built on top of SwiftUI. The app allows the user to estimated amount of $ to pay for the insurance costs based on some feature, such as: sex, age, child, smoke, bmi.

An enhancement built on top of Foundation Framework and XCTest.

Beton is a Swift library built on top of the Foundation framework, that provides an additional layer of functionality, including easy localization, performance test measurement support, and convenience functionality. For us, Beton is primarily, but not exclusively, useful for server-side Swift engineering.

Full featured multi arch/os debugger built on top of PyQt5 and frida

Dwarf A debugger for reverse engineers, crackers and security analyst. Or you can call it damn, why are raspberries so fluffy or yet, duck warriors ar

A custom layout built on top of SwiftUI's Layout API that lays elements out in multiple lines. Similar to flex-wrap in CSS, CollectionViewFlowLayout.
A custom layout built on top of SwiftUI's Layout API that lays elements out in multiple lines. Similar to flex-wrap in CSS, CollectionViewFlowLayout.

WrapLayout A custom layout built on top of SwiftUI's Layout API that lays elements out in multiple lines. Similar to flex-wrap in CSS, CollectionViewF

Comments
  • Support for Xcode 8.1

    Support for Xcode 8.1

    Ecno is not compiling in Xcode 8.1/Swift 3.0.1

    There are two errors in file Ecno.swift:

    • Ecno.swift:199:25: Binary operator '>=' cannot be applied to operands of type 'Date' and 'Date!'
    • Ecno.swift:201:25: Binary operator '>=' cannot be applied to operands of type 'Date' and 'Date!'
    opened by m-revetria 0
Releases(3.0.0)
Owner
xmartlabs
xmartlabs
Strong typed, autocompleted resources like images, fonts and segues in Swift projects

R.swift Get strong typed, autocompleted resources like images, fonts and segues in Swift projects Why use this? It makes your code that uses resources

Mathijs Kadijk 8.9k Jan 6, 2023
SwiftGen is a tool to automatically generate Swift code for resources of your projects

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

null 8.3k Jan 5, 2023
Soulful docs for Swift & Objective-C

jazzy is a command-line utility that generates documentation for Swift or Objective-C About Both Swift and Objective-C projects are supported. Instead

Realm 7.2k Jan 3, 2023
Laurine - Localization code generator written in Swift. Sweet!

Author's note: Thanks everyone for making Laurine the TOP trending Swift repository in the world - this is amazing and very heart-warming! But this is

Jiri Trecak 1.3k Dec 28, 2022
swiftenv allows you to easily install, and switch between multiple versions of Swift.

Swift Version Manager swiftenv allows you to easily install, and switch between multiple versions of Swift. This project was heavily inspired by pyenv

Kyle Fuller 1.9k Dec 27, 2022
Script to support easily using Xcode Asset Catalog in Swift.

Misen Misen is a script to support using Xcode Asset Catalog in Swift. Features Misen scans sub-directories in the specified Asset Catalog and creates

Kazunobu Tasaka 123 Jun 29, 2022
An Xcode Plugin to convert Objective-C to Swift

XCSwiftr Convert Objective-C code into Swift from within Xcode. This plugin uses the Java applet of objc2swift to do the conversion. Noticed that the

Ignacio Romero Zurbuchen 338 Nov 29, 2022
Swift autocompleter for Sublime Text, via the adorable SourceKitten framework

SwiftKitten SwiftKitten is a Swift autocompleter for Sublime Text, via the adorable SourceKitten framework. Faster than XCode ! This package is new an

John Snyder 142 Sep 9, 2022
Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, configurations and app-state. UserDefaults

Prephirences - Preϕrences Prephirences is a Swift library that provides useful protocols and convenience methods to manage application preferences, co

Eric Marchand 557 Nov 22, 2022
Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD).

Queuer is a queue manager, built on top of OperationQueue and Dispatch (aka GCD). It allows you to create any asynchronous and synchronous task easily, all managed by a queue, with just a few lines.

Fabrizio Brancati 1k Dec 2, 2022