/
ProductsController.m
92 lines (71 loc) · 2.02 KB
/
ProductsController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// ProductsController.m
// InAppPurchasingExample
//
// Created by Adam Darton on 12-03-14.
// Copyright (c) 2012 Bonobo. All rights reserved.
//
#import "ProductsController.h"
@implementation ProductsController
@synthesize iapCatalogue;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
self.iapCatalogue = [[IAPCatalogue alloc] init];
[self.iapCatalogue load:self];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
#pragma mark - Button Actions -
-(IBAction)onBackButtonTouchUp:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
#pragma mark - IAPCatalogueDelegate -
-(void)iapCatalogue:(IAPCatalogue*)catalogue didLoadProductsFromCache:(NSArray*)products{
NSLog(@"Loaded From Cache %d", [products count]);
}
-(void)iapCatalogue:(IAPCatalogue*)catalogue didLoadProducts:(NSArray*)products{
NSLog(@"Loaded %d", [products count]);
}
-(void)iapCatalogueDidFinishLoading:(IAPCatalogue*)catalogue{
NSLog(@"Loaded catalogue");
}
-(void)iapCatalogue:(IAPCatalogue*)catalogue didFailWithError:(NSError*)error{
NSLog(@"Failed: %@", error.description);
}
@end