posting NSNotificationCenter events

Post here your questions about the Objective-C API for SFS2X

Moderators: Lapo, Bax

mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

posting NSNotificationCenter events

Postby mmilen » 16 May 2014, 16:58

Hi,

Would be possible sometimes down the road to add NSNotificationCenter events in addition to the delegate events. I'm working on a project that require pretty loose integration with SFS. I have added code to forward all delegate events to NSNotificationCenter it would be nice if we can hook up to those directly.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: posting NSNotificationCenter events

Postby Lapo » 16 May 2014, 19:12

This would possibly involve duplicating the event dispatching system which may add confusion to the API. In general we have tried to follow two rules:

1- make the API consistent across languages
2- use specific features of the language that developers are familiar with

It's a bit tricky to balance the two aspects because they may conflict, but it helps when switching from platform to another and when learning from examples done in languages other than the favorite one(s). In other words you can study a game example in C# and still be able to easily transport the code to Obj-C or C++ (or any other) thanks to a consistent mode of programming.

With this said I would probably suggest to build a simple layer of abstraction between your code and the API so that they remain loosely coupled.
Lapo
--
gotoAndPlay()
...addicted to flash games
mmilen
Posts: 298
Joined: 09 Nov 2010, 00:48
Contact:

Re: posting NSNotificationCenter events

Postby mmilen » 16 May 2014, 20:50

Thanks, make sense. This is what I have done , abstracted he delegate.

Return to “SFS2X iPhone / iPad / OSX API”

Who is online

Users browsing this forum: No registered users and 16 guests