last day (14 days later) » 

12:57 AM
0
Q: Label not changing its value

emiliomarinI'm trying to use In-App Purchases and I want to sent a label to the title of the IAP that I have. The problem is that it doesn't update(change), but if I do a NSLog for the product.localizedTitle I get the result. All variables are synthesized and if I set the label to @"Hello" in the viewDidLoa...

 
I guess it's not nil because the NSLog wouldn't show the right result
I have connected the IBOutlets.
 
Can you just log productTitle to be sure it's not nil (right before your set its text).
 
@rdelmar If I do NSLog(@"%@", productTitle.text); before I get (null) and if I do it after I get the same
 
We want yo to log NSLog(@"%@",productTitle) not the text!
 
Sorry, I get the same result (null)
 
12:57 AM
Ok, that means you either didn't connect the outlet properly, or the controller you're working on with this code is not the one where you connected the outlet in IB.
 
Hi
I checked and the connections are right
 
You said you set the text to "Hello" in viewDidLoad. Is that in the same controller where you have this code?
That was for productTitle?
 
Yes
Same controller in the viewDidload
That's why I'm confused
 
Have you set productTitle to nil somewhere? it doesn't make sense that you could set it properly in viewDidLoad, but now it's n ill.
*nil
 
I don't think so. Would you mind taking a look to the app? It's just a simple one trying to make the iap
 
1:04 AM
Sure. I'll look at it.
 
Ok, give me a minute, and I'll check it out.
 
Thanks!
 
1:18 AM
Ok, I found the problem
 
what was it?
 
Your "Buy Item" button has a segue attached to it, but then you also have an IBAction for that button where you call presentViewController:animated:completion:. You shouldn't do both
You're also instantiating the controller incorrectly in that IBAction
 
If I don't do the segue the screen goes black when the button is pressed
And if I don't do the presentViewController:animated:completion: it still the same
 
When you connect a segue from a button, the new controller is instantiated and presented, without any code. You shouldn't create a new controller (which you do) and then present it in code.
You should get rid of the IBAction, and put in prepareForSwegue instead.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
_purchaseController = segue.destinationViewController;
_purchaseController.productID = @"com.marinemilio.inapppurchases.IAP1";
[[SKPaymentQueue defaultQueue] addTransactionObserver:_purchaseController];
[_purchaseController getProductID:self];

}
Also, in IB, right click on the "But Item" button, and delete the IBAction you have connected to it.
*"Buy Item"
 
Yes Yes, you are totally right
Thank you so much, I've been all day with this
 
1:25 AM
Ok, bye.
 

last day (14 days later) »