Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
I am having problems adding objects to my NSMutableArray. It seems that something gets added (object count increases by 1 in debugger), but the only thing added is a 0x0 (null) instead of the address of an object. I've read through everything somewhat relevant that I could find, but I couldn't find anything that seemed to answer this issue. Most related posts seem to revolve around memory management, but the solution is not jumping out at me.
I appreciate any help you can provide.
I've included what I think are the relevant parts of the code. Please tell me if you need to see anything more.
[self.boardObjects addObject: mine]; // Second breakpoint here topObject = 1;
[super viewDidLoad];
} // End viewDidLoad
I put breakpoints at the addObject lines (commented in code). When execution stops at the first breakpoint, the debugger shows a good tempPlayer, and a good gamePlayer (both non-null, with the same address). It shows 0 objects in boardObjects, like this:
boardObjects = (_NSArrayM *) 0x4b22080 0 objects
When I step over this breakpoint, the debugger shows 1 object in boardObjects, as follows:
When I continue program execution, and the debugger stops at the next breakpoint, I also see a good mine object, with boardObjects still described as above. After stepping over this breakpoint, boardObjects now looks like this:
NSLog(@\"self.boardObjects is: %@\", [self.boardObjects description]);
Are you experiencing an actual problem in your app - which you didn't describe - or are you merely concerned about what you're reading from the debugger?
baja_yu: The releases are in the code, I just didn't show them. Thanks for the tip on moving the call to super to the top. I did that, with no change to what I was observing.
Brian: I was surprised to see that your NSLog revealed actual contents in the boardObjects array! Thank you. I suppose I had no problem after all.
However, I put a breakpoint at the NSLog line, and the debugger still shows 0x0 for each array entry, both before the NSLog line, and after it executes. Does this mean I'll never be able to get to array contents directly in the debugger?
To your question, I hadn't tried to proceed past this point in my app yet. I'll eventually be dynamically adding and removing hundreds of objects to this array, and I needed it to work properly before proceeding.
Replies
Also, in viewDidLoad the call to super should come before all other code.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeAre you experiencing an actual problem in your app - which you didn't describe - or are you merely concerned about what you're reading from the debugger?
SlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeBrian: I was surprised to see that your NSLog revealed actual contents in the boardObjects array! Thank you. I suppose I had no problem after all.
However, I put a breakpoint at the NSLog line, and the debugger still shows 0x0 for each array entry, both before the NSLog line, and after it executes. Does this mean I'll never be able to get to array contents directly in the debugger?
To your question, I hadn't tried to proceed past this point in my app yet. I'll eventually be dynamically adding and removing hundreds of objects to this array, and I needed it to work properly before proceeding.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome