Git Product home page Git Product logo

consecutive's Introduction

Consecutive

A pretty basic implementation to help keep track of a users streak of days where he/she has launched your app.

The component uses NSUserDefaults to keep track of the dates. It also makes use of NSDate+Helpers category used in the PMCalendar repo here: https://github.com/kovpas/PMCalendar which is MIT Licensed.

Install:

Copy TMConsecutiveDayHelper.h and TMConsecutiveDayHelper.m into your project as well as NSDate+Helpers.h and NSDate+Helpers.m.

Place a call to:

    [TMConsecutiveDayHelper appLaunched];

In your App Delegate's application didFinishLaunchingWithOptions: method

Then to check on your users streak you can call:

[TMConsecutiveDayHelper streakSizeInDays];

Or Alternatively call:

[TMConsecutiveDayHelper hasComeBackForThisExactNumberOfDaysConsecutively:5]

which returns a BOOL

Basically you're responsible for what you want to do with the info and the class just keeps track of the streak itself.

Downsides:

Because the app uses NSUserDefaults it could be gamed pretty easily, by the user changing the date on their device. The component also uses ARC so if your project is using reference counting (ie retain release) then place the compiler flag ' -fobjc-arc ' inside the TMConsecutiveDayHelper.m row under the 'Compile Sources' located within the 'Build Phases' Tab for your App/Target settings.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.