TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
Want something to happen the first time someone views the first screen of your app? What about the third time they view the products list? PDCounter
helps you track events, notify observers when they happen, and review a history of every discreet, named event.
git clone https://github.com/wileykestner/PDCounter.git
Add PDCounter.xcodeproj
file as a dependancy of your project
Add PDCounter-StaticLib
in your app target's Build Phases > Target Dependendencies
Add libPDCounter.a
in your app target's Build Phases > Link Binary With Libraries
Add <CoreData/CoreData.h>
in your app target's Build Phases > Link Binary With Libraries
Add the path the PDCounter
public header files in your target's Build Settings > Header Search Paths
, ex: "$(PROJECT_DIR)/Externals/PDCounter/PDCounter/Public/Headers/"
// YourAppsController.m
#import "PDCounterProvider.h"
@implementation YourAppsController
- (void)viewDidLoad {
[super viewDidLoad];
PDCounterProvider *counterProvider = [[PDCounterProvider alloc] init];
id <PDCounter> counter = [counterProvider counter];
[counter increment:@"my_event_name" step:1];
NSLog(@"The event 'my_event_name' has happened %d time(s)", [counter currentCount:@"my_event_name"]);
}
@end
Any object that conforms to the PDCounterObserver
protocol can be added as an observer of counting events.
id<PDCounterObserver> observer = [[MySpecialObject alloc] init];
PDCounterProvider *counterProvider = [[PDCounterProvider alloc] init];
id <PDCounter> counter = [counterProvider counter];
[counter addObserver:observer];
Now the MySpecialObject
instance, observer
, will have its counter:didIncrement:newCount:
method called every time counter
has increment:step:
called on it.
Specs
git clone https://github.com/wileykestner/PDCounter.git
git submodule update --init
cd PDCounter
rake specs