0

I want to sell products inside my app. I receive my products properly but i can't display them through the NSNotificationCenter. Here is my code :

- (void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response {

    NSLog(@"Received products results...");
    self.products = response.products;
    self.request = nil;

    NSLog(@"%@", self.products); // I got the products (SKProduct)

  [[NSNotificationCenter defaultCenter] postNotificationName:kProductsLoadedNotification object:_products];
}

I tried to display a simple notification too, but it doesn't work either:

[[NSNotificationCenter defaultCenter] postNotificationName:@"my_notification" object:nil];

I also tried this

Can't you help me to figure this out?

Community
  • 1
  • 1
user5329034
  • 110
  • 1
  • 1
  • 8
  • Did you addObserver in VC where it was needed? – Varun Jul 07 '16 at 09:44
  • I added the observer to the VC this way: http://hastebin.com/ipezenohul.sm and the prototype of productsRequest to VC.h. It now results to a SIGABRT at the call of the NotificationCenter – user5329034 Jul 07 '16 at 10:17
  • are you sure the Notification names are same..? One in hastebin. Code is "ProductsLoaded" and here it is "kProductsLoadedNotification" – Jen Jose Jul 07 '16 at 11:06
  • Yes they are the same – user5329034 Jul 07 '16 at 11:34
  • 1
    Also the object should be nil. The notification will only be called if the object is nil. If you want to send the data to other VC, you should make use of userInfo available in NSNotificationCenter method – Varun Jul 07 '16 at 12:10
  • Solved, I passed an NSDictionnary with my products information through the userInfo available in NSNotificationCenter. – user5329034 Jul 12 '16 at 13:12

0 Answers0