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

  • SEARCH
  • Home
  • 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 9260633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:56:32+00:00 2026-06-18T12:56:32+00:00

My code: NSArray *keys = [piecesDict allKeys]; //keys are NSStrings of sprite names, piecesDict

  • 0

My code:

     NSArray *keys = [piecesDict allKeys]; 
    //keys are NSStrings of sprite names, piecesDict is NSDictionary

    for(int i = 0; i < piecesDict.count; i++){
        PuzzlePiece *piece;
        id key = [keys objectAtIndex:i];
        piece.keyName = key; }

The exact code that crashes is piece.keyName = key. I get EXC_BAD_ACCESS. The .keyName property is (nonatomic, retain). I have tried making key an NSString * or casting it with (NSString *)key to no avail.

What am I missing here?

  • 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-18T12:56:34+00:00Added an answer on June 18, 2026 at 12:56 pm

    You don’t initialize piece, you just declare a pointer and leave it hanging in the air. It will point to random crap and crash. You need to assign it to a proper instance:

    PuzzlePiece *piece = [[PuzzlePiece alloc] init]; // or whatever
    

    And seriously: do learn C well before attempting to make iOS apps or you will shoot yourself and your users in the foot.

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

Sidebar

Related Questions

Aim: To obtain an NSArray containing unique keys for given NSDictionary(s) using elegant code
Here is my piece of code that creates buttons programmatically: NSArray *buttonImage=[NSArray arrayWithObjects:[UIImage imageNamed:@Cover_0.png],
I have this code NSDictionary *tempDict = [NSDictionary dictionaryWithObjects: [NSArray arrayWithObjects:@authorId,authorName,authorDescription,@image,nil] forKeys: [NSArray arrayWithObjects:@id,@name,@desc,@image,nil]];
In centralManager:didDiscoverPeripheral:advertisementData:RSSI (complete code below), I'm finding a key in the NSDictionary called kCBAdvDataServiceUUIDs.
I was checking out this question which has this code - (NSArray *) percentagesRGBArray:(float[])
I am trying to record using the iphones microphone: This is my code: NSArray
I have code that works great for adding a button to the toolbar: NSArray*
Here is the code that I have for my cell of my UITableView: forKeys:[NSArray
So, this is my code : - (void)runCmd:(NSString *)cmd withArgs:(NSArray *)args { NSLog(@\nRunning ::\n\tCmd
I have an array of keys/values... NSArray *keysAndValues = @[@1, @one, @2, @two, @3,

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.