Skip to content

ivmirx/HubObjC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hub

This is a strongly-typed message hub for Objective-C that I used for a while instead of NSNotificationCenter. It's now kind of deprecated because of iOS 9 NSNotification improvements.

Subscribing

[[Hub shared] subscribeMethod:@selector(onSomeTestMsg:)
					 atObject:self
				   forMessage:[SomeHubMsg class]];

Unsubscribing

You must unsubscribe in -viewWillDisappear: or -dealloc.

[[Hub shared] unsubscribeMethod:@selector(onSomeTestMsg:)
					   atObject:self
					fromMessage:[SomeHubMsg class]];

Sending Messages

SomeHubMsg *msg = [SomeHubMsg messageWithValue:12345];
[[Hub shared] send:msg];

Receiving Messages

- (void)onSomeTestMsg:(SomeHubMsg *)msg
{
	self.resultText.text = [NSString stringWithFormat:@"Received value: %li", msg.value];
}

About

Strongly-typed message hub for Objective-C

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published