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 8022573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:18:07+00:00 2026-06-04T22:18:07+00:00

This problem has been confusing me for days now. I have an NSString, ‘spriteType’.

  • 0

This problem has been confusing me for days now. I have an NSString, ‘spriteType’. It is declared using the property and synthesise method. In my layer, where the string is created, I also create a CCNode. The node is created in a method.

- (void) spritePick {

CCMenuItemImage *go = [CCMenuItemImage itemFromNormalImage:@"button_go.png" selectedImage:@"button_go_selected.png" target:self selector:@selector(test)];
spritePickMenu = [CCMenu menuWithItems:go, nil];
spritePickMenu.position = ccp(0,0);

spritePick = [CCNode node];
[spritePick addChild:spritePickMenu];
spritePick.position = ccp(240,160); 
[self addChild: spritePick];
}

The ‘test’ method, which is called from the button, is simple:

- (void) test {
NSLog(@"%@",spriteType);
}

The NSLog line crashes my game, and gives the error: EXC_BAD_ACCESS

Anywhere apart from inside the ‘test’ method, the code works fine. Why would it be giving me the error when the method has been called from the Node, but it would not give it to me when it has been called from anywhere else?

I can give you the full code if required.

  • 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-04T22:18:08+00:00Added an answer on June 4, 2026 at 10:18 pm

    Which attributes are you using for your spriteType property declaration?

    If your project is using ARC, the header should look like:

    @property (nonatomic, strong) NSString *spriteType;
    

    While the implementation should look like:

    @synthesize spriteType = spriteType_;
    

    If you declare/synthesize your property this way, then NSLog(@"%@", self.spriteType) just writes (null) to the console (I tested to double-check).

    It’s a good practice to access your properties using self. rather than trying to access the backing ivar directly.

    Since you’re seeing EXC_BAD_ACCESS I assume you aren’t maintaining a strong reference to self.spriteType.

    If your project is using ARC, you need to be sure you’re compiling with LLVM 3.0 or greater, as detailed in this answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This Jquery problem has been bugging me for a while now. I developed a
This problem has bugged me so many times and i have now decided to
I have a problem that has been consuming me for days. I have a
This problem has been bugging me since forever. I have an array and in
This problem has been solved! Thanks a lot to Brad, Denis and junkie! You're
EDIT: This problem has been solved. See below. Hey all. I'm building an iPhone
UPDATE It looks like this problem has been quietly fixed in iOS 4.3. Up
Edit : The bug that caused this problem has been fixed. The @version tag
There was this problem that has been asked about implementing a load byte into
Update II Problem Solved but Why? This has been the biggest headache ever. My

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.