ios - Accessing SKProductResponse from outside of object -


i'm integrating in app purchase app , have created object implements delegate callback:

- (void)productsrequest:(skproductsrequest *)request didreceiveresponse:(skproductsresponse *)response {     nsarray *myproduct = response.products;     // populate ui     [request autorelease]; } 

as 1 of methods.

in case have multiple skproduct objects returned response.products. i'd able access myproduct array outside of object in view controller reflect of skproduct details price , product description.

here's interface declaration in app purchase class:

@interface inapppurchasemanager : nsobject <skproductsrequestdelegate, skpaymenttransactionobserver> {      nsarray *myproducts;     skproductsrequest *productsrequest;  }  // public methods - (void)loadstore; - (bool)canmakepurchases; - (void)purchasefeature:(nsstring *)productid;  @property (nonatomic, retain) nsarray *myproducts;  @end 

then viewdidload method in view controller:

- (void) viewdidload {         /* instantiate inapppurchasemanager object kick off collect product info */     iapmanager = [inapppurchasemanager new];     [iapmanager loadstore];      skproduct *myproduct;      (myproduct in iapmanager.myproducts) {             nslog(@"product title: %@" , myproduct.localizedtitle);         nslog(@"product description: %@" , myproduct.localizeddescription);         nslog(@"product price: %@" , myproduct.price);         nslog(@"product id: %@" , myproduct.productidentifier);     }  } // end viewdidload 

i exception:

[inapppurchasemanager myproducts]: unrecognized selector sent instance 0x162d60

what doing wrong here, , how can "export" skproduct data view controller? ideas appreciated!

also, in productsrequest: method, i'm able use nslog , print through same loop , see skproduct data beautifully reflected in console output; doesn't work in viewdidload method.

ok. there number of things missing. carl getting me pointed in right direction:

1) missing synthesize statements myproducts in both inapppurchasemanager.m file , viewcontroller.m file. 2) needed @property statements myproducts in viewcontroller.h file. 3) needed set myproducts property using self in productsrequest method of inapppurchasemanager.m file:

self.myproducts = response.products; 

this why data held in myproducts never visible in viewcontroller.

hope helps else out there!


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -