iphone sdk应用程序内购买错误
我在应用程序中实现了应用内购买。我需要在我的应用程序中使用应用内购买来购买产品。为此,我在iTunes a/c中添加了我的产品应用程序id 这是我的代码参考 代码: ViewController.miphone sdk应用程序内购买错误,iphone,ios,in-app-purchase,Iphone,Ios,In App Purchase,我在应用程序中实现了应用内购买。我需要在我的应用程序中使用应用内购买来购买产品。为此,我在iTunes a/c中添加了我的产品应用程序id 这是我的代码参考 代码: ViewController.m NSMutableArray *featuredappidArray; - (void)viewDidLoad { [super viewDidLoad]; featuredappidArray=[[NSMutableArray alloc]init]; } -(void)parseR
NSMutableArray *featuredappidArray;
- (void)viewDidLoad
{
[super viewDidLoad];
featuredappidArray=[[NSMutableArray alloc]init];
}
-(void)parseRecentPosts:(NSString*)responseString
{
NSString *app_store_id = [NSString stringWithFormat:@"%@",[post objectForKey:@"app_store_id"]];
NSLog(@"Recent Post app_store_id: %@",app_store_id);
[featuredappidArray addObject:app_store_id];
indexvalue=ndx;
}
- (void)buttonTapped:(UIButton *)sender
{
[detailview Receivedappidurl:featuredappidArray idx:indexvalue];
}
NSMutableArray *appidArray;
-(void)Receivedappidurl:(NSMutableArray*)recentappidArray idx:(int)index
{
NSLog(@"recentappidArray:%@",recentappidArray);
appidArray=recentappidArray;
}
DetailViewController.h
-(void)Receivedappidurl:(NSMutableArray*)recentappidArray idx:(int)index;
DetailViewController.m
NSMutableArray *featuredappidArray;
- (void)viewDidLoad
{
[super viewDidLoad];
featuredappidArray=[[NSMutableArray alloc]init];
}
-(void)parseRecentPosts:(NSString*)responseString
{
NSString *app_store_id = [NSString stringWithFormat:@"%@",[post objectForKey:@"app_store_id"]];
NSLog(@"Recent Post app_store_id: %@",app_store_id);
[featuredappidArray addObject:app_store_id];
indexvalue=ndx;
}
- (void)buttonTapped:(UIButton *)sender
{
[detailview Receivedappidurl:featuredappidArray idx:indexvalue];
}
NSMutableArray *appidArray;
-(void)Receivedappidurl:(NSMutableArray*)recentappidArray idx:(int)index
{
NSLog(@"recentappidArray:%@",recentappidArray);
appidArray=recentappidArray;
}
现在,我的控制台窗口接收来自我的web服务的所有应用程序id
我在我的项目中添加了应用内购买所需的类,如IAPHelper、InAppRageIAPHelper、MBProgressHUD、可达性类
-(IBAction)purchaseButton
{
NSLog(@"appidarray:%@",appidArray);
NSLog(@"pdt index:%d",productIndex);
NSLog(@"APPLe indentifier:%@",[[appidArray objectAtIndex: productIndex] objectForKey: @"app_store_id"]);
[InAppRageIAPHelper sharedHelper].productIndex = productIndex;
[[InAppRageIAPHelper sharedHelper] buyProductIdentifier:[[appidArray objectAtIndex: productIndex] objectForKey: @"app_store_id"]];
self.hud = [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
_hud.labelText = @"Buying Book...";
[self performSelector:@selector(timeout:) withObject:nil afterDelay:60*5];
}
当我点击“购买”按钮时,我的应用程序崩溃并出现以下错误,
“由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:”-[\uu NSCFString objectForKey:]:发送到实例0x9154ad0的选择器无法识别”
我参考了很多教程。如何使用它购买?请帮我解决这个问题。任何帮助都将不胜感激。提前感谢。这会使您的代码崩溃
[[appidArray objectAtIndex: productIndex] objectForKey: @"app_store_id"]
这很可能是因为[appidArray objectAtIndex:productIndex]
返回字符串,而不是字典
第一步:您需要像下面这样从商店加载项目:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
SKProductsRequest *productsRequest = [[[SKProductsRequest alloc] initWithProductIdentifiers:yourProductIdentifiers autorelease];
productsRequest.delegate = self;
[productsRequest start];
另外,您可以在web上的管理InApp采购部分找到您的产品标识符
完成此操作后,您将收到一份产品列表,您可以购买其中任何一种产品:
SKPayment *payment = [SKPayment paymentWithProduct:product];
[[SKPaymentQueue defaultQueue] addPayment:payment];
这正在破坏你的代码
[[appidArray objectAtIndex: productIndex] objectForKey: @"app_store_id"]
这很可能是因为[appidArray objectAtIndex:productIndex]
返回字符串,而不是字典
第一步:您需要像下面这样从商店加载项目:
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
SKProductsRequest *productsRequest = [[[SKProductsRequest alloc] initWithProductIdentifiers:yourProductIdentifiers autorelease];
productsRequest.delegate = self;
[productsRequest start];
另外,您可以在web上的管理InApp采购部分找到您的产品标识符
完成此操作后,您将收到一份产品列表,您可以购买其中任何一种产品:
SKPayment *payment = [SKPayment paymentWithProduct:product];
[[SKPaymentQueue defaultQueue] addPayment:payment];
好的。所有应用程序id都在我的阵列中。现在我该如何继续?购买我的产品?好的。所有应用程序id都在我的阵列中。现在我该如何继续?购买我的产品?