I'm trying to implement the RMStore library for in-app purchases for my app. But I don't know what they mean with the observer/notifications. Link: Click here for the website
Can someone explain this to my what the purpose is of this "Observer" and where do I need to put these?
([[RMStore defaultStore] addStoreObserver:self]; [[RMStore defaultStore] removeStoreObserver:self];
) in the same class as my buy/restore methods? Already tried to understand, but can't find any good information. Can someone make this clear for me?
Do I need to place the observer ([[RMStore defaultStore] addStoreObserver:self]; [[RMStore defaultStore] removeStoreObserver:self];) in the same class as my buy/restore methods?
No, you don't need to put it anywhere. However, if you use an observer, it will most likely simplify the code needed to deal with border cases.
If so, what do they do? Does the addStoreObserver tell the library RMStore for executing the method for the bought products like in my Buy Method in the class?
They're a convenient way to react to transaction events from anywhere in your app. For example, if your app is killed before a transaction finishes, you will (eventually) be notified about the transaction after the app is opened again, and the user might not be in the view controller that started the transaction. An observer placed somewhere in your app logic can take care of this easily.
Or do I need to put the observers somewhere else?
See first answer.
And what is the general purpose of an observer?
In RMStore observers are used as a typed wrapper over notifications. If you want to learn more about this technique, here's an article about implementing the Observer pattern with notifications.