Latest 1.1.2
License MIT
Platforms ios 8.0

STNotifications: Strongly Typed Notifications for Objective C

Build status
Code coverage status

STNotifications is Objective-C library for Strongly Typed Notifications


  • [x] Strongly typed payload (using safe api around Objective-C lightweight generics)
  • [x] Makes sure only one NSNotificationName exists for Notification and Observer
  • [x] You have pointer to sender from recieved notification!
  • [x] Interoperable with Swift!
  • [x] Autounsubscribtion on NotificationToken deallocation!


Create factory method

#import <STNotifications/STNotifications.h>
@class Alert;

@interface STNotificationFactory (YourCustomNotifications)
+ (STNotificationFactory<Payload *> *)payloadFactory;

@implementation STNotificationFactory (YourCustomNotifications)
+ (STNotificationFactory<Payload *> *)payloadFactory {
    return [STNotificationFactory factoryWithNotificationName:@"Notification payload"];

or your own subclass:

#import <STNotifications/STNotifications.h>
#import "Payload.h"

@interface PayloadNotificationFactory : STNotificationFactory <Payload *>
+ (instancetype)factory;

#import "PayloadNotificationFactory.h"

@implementation PayloadNotificationFactory

+ (instancetype)factory {
    return [PayloadNotificationFactory factoryWithNotificationName:@"PayloadNotification"];

That’s it! Now your NotificationName and Payload Type can be no longer be messed up!

Start observing

Autocompletion will insert payload type you specified in factory same way as it’s in NSArray!
 STNotifications: Strongly Typed Notifications for Objective C

@property (strong, nonatomic) STNotificationToken *token; // < ---- Auto Unsubscription on deallocation!

 STNotificationObserver *observer = [[AlertNotificationFactory factory] makeObserverWithOnRecievedBlock:^(STNotification<Alert *> * _Nullable notification) {
        NSLog(@"%@", notification.payload.message);
        NSLog(@"%@", notification.sender);
self.token = [[NSNotificationCenter defaultCenter] stn_addNotificationObserver:observer];

You can track down sender of notification!
STNotificationToken has autounsubscription feature on deallocation!

Post notification

You can no longer mess up payload type!
 STNotifications: Strongly Typed Notifications for Objective C

  Alert *alert = [Alert new];
  alert.message = @"ALARM!!!";
  STNotification *alertNotification = [[AlertNotificationFactory factory] makeNotificationWithPayload:alert sender:self];
  [[NSNotificationCenter defaultCenter] stn_postNotification:alertNotification];



target '<Your Target Name>' do
    pod 'STNotifications', '~> 1.1.2'


github "neisip/StronglyTypedNotifications"


STNotifications is released under the MIT license. See LICENSE for details.

Latest podspec

    "name": "STNotifications",
    "version": "1.1.2",
    "summary": "Tiny library for Strongly Typed Notifications in Objective-C",
    "description": "Strongly typed notificatinos allow your Objective-C notifications to work in a safe manner, using light generics magics and little bit of architecture tricks!nBenefits:n1) Strongly typed payloadn2) NSNotification name won't be messed again!n3) Easy syntax for usen4) Interoperable with swift!n5) 100% Code Coverage!",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Alexander Kazartsev": "[email protected]"
    "platforms": {
        "ios": "8.0"
    "source": {
        "git": "",
        "tag": "1.1.2"
    "source_files": [
    "exclude_files": "Classes/Exclude"

Pin It on Pinterest

Share This