Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9068391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:10:49+00:00 2026-06-16T17:10:49+00:00

I’m new with cocos2d so i’ve got a problem with my In-App Purchase Class

  • 0

I’m new with cocos2d so i’ve got a problem with my In-App Purchase Class Helper. I wrote game in Cocoa Touch and this class working perfectly, but i’m writing now the same game in Cocos2d and problem is with NSString.

Here are some snippets.

This method is called as first when i clicked some button. As you see completeIdentifier is simple string with bundleIdentifier and some string parameter. It’s ok, in this place i can log this completeIdentifier.

- (void)prepareToPurchaseItemWithIdentifier:(NSString *)aIdentifier showAlertWithTitle:(NSString *)title description:(NSString *)description delegate:(id)aDelegate{

    self.delegate = aDelegate;

    identifier = aIdentifier;
    completeIdentifier = [NSString stringWithFormat:@"%@.%@", [[NSBundle mainBundle] bundleIdentifier], aIdentifier];

    askToPurchase = [[UIAlertView alloc] initWithTitle:title message:description delegate:self cancelButtonTitle:nil otherButtonTitles:@"Later", @"Yes", nil];
    askToPurchase.delegate = self;
    [askToPurchase show];
}

Next method is UIAlertViewDelegate method. Is called when i click YES on alertView from first method.

#pragma mark - UIAlertViewDelegate Methods
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"%@", completeIdentifier);
    if (alertView == askToPurchase) {

        NSLog(@"[TSIAPHelper] Clicked YES. Prepare...");
        if ([SKPaymentQueue canMakePayments]) {

            NSLog(@"[TSIAPHelper] Prepare to purchase [%@].",completeIdentifier);
            SKProductsRequest *request =[[SKProductsRequest alloc] initWithProductIdentifiers:
                                     [NSSet setWithObject:completeIdentifier]];
            request.delegate = self;
            [request start];

            pleaseWait = [[UIAlertView alloc] initWithTitle:@"Please wait..." message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
            UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
            [activity startAnimating];
            [pleaseWait addSubview:activity];
            activity.frame = CGRectMake(125, 50, 36, 36);
            [pleaseWait show];
        }
        else {

            NSLog(@"[TSIAPHelper] Purchase [FAILURE]. Prohibited by Parentar Control or something like that.");
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Prohibited." message:@"Parental Control is enabled, cannot make a purchase. Turn off and try again." delegate:self cancelButtonTitle:nil otherButtonTitles:@"Ok", nil];
            [alert show];
        }
    }
}

The problem is: Whenever and anywhere i want to Log variable completeIdentifier i’ve got crash with selected line: 0x39e965d0: ldr r3, [r4, #8] but i don’t know what’s that mean. And this line is selected:

NSLog(@"%@", completeIdentifier);

How can i fix it? In Cocoa Touch is working perfectly. When i use cocos2d isn’t.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T17:10:50+00:00Added an answer on June 16, 2026 at 5:10 pm

    I guess you aren’t using ARC. In this case completeIdentifier will be autoreleased.

    Cocos2d clears the autoreleasepool every frame, whereas in Cocoa this is not strictly defined but may still crash. You can fix this by retaining or copying the string.

    completeIdentifier = [NSString stringWithFormat:@"%@.%@", [[NSBundle mainBundle] bundleIdentifier], aIdentifier];
    completeIdenfitier = [completeIdentifier retain];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.