Amazon.com Widgets Program 7.5 memory problems
Welcome, Guest. Please login or register.
Did you miss your activation email?
July 31, 2014, 04:28:02 AM
Home Help Search chat Login Register 
News: Read this please.The Great Kangaroo Escape Looking for reviews of the 4th ed on Amazon!   Twitter:  @skochan
                     

+ Official Forum for Programming in Objective-C (the iPhone Programming Language) - Stephen Kochan
|-+ Old Stuff
| |-+ Program Examples
| | |-+ Chapter 7
| | | |-+ Program 7.5 memory problems
Pages: [1] Go Down
Print
Author Topic: Program 7.5 memory problems (Read 1117 times)
dtaur456
Newbie
*
Posts: 2






on: October 18, 2010, 04:41:28 PM

I copied  the program exactly as it said from the book.  The build and run provided me with a EXC_BAD_ACCESS message (came from console).  I did a build and analyze and was caught with a memory leakage in the implementation file.  I read the Memory Management Guide for Cocoa and I got totally lost.

my Fraction Test 5.m file is at the bottom of the pictures.

Please help!
Logged
skochan
Administrator
Hero Member
*****
Posts: 3114







Reply #1 on: October 24, 2010, 11:35:50 AM

I don't see any problems with your code.  The analyzer is warning you that you are returning an object that you allocated in a method.  As noted later in the chapter, that's not good programming practice (you'll learn later that you can "autorelease" the object).  The analyzer is also telling you that if you do return an object that the user is responsible for releasing, you should make that clear in the name of the method (using the terms "copy", "alloc," or "new"--also discussed later in the book).

The type of error you're getting could occur if you were using the older definition of the add: method, which doesn't return a value.  Any chance that's happening?  Can you try doing a Build > Clean All Targets and then a Build and Run?   If that doesn't work, after the clean, zip up and post your project folder and i'll have a look.

Cheers,

Steve
Logged
dtaur456
Newbie
*
Posts: 2






Reply #2 on: October 26, 2010, 10:45:53 AM

"The analyzer is also telling you that if you do return an object that the user is responsible for releasing, you should make that clear in the name of the method (using the terms "copy", "alloc," or "new"--also discussed later in the book)."

What name of what method?
I'm well aware that this can't possibly be right, but  am I supposed to call my "Add" method "copyAdd"?

I confused by the wording: "you should make that clear in the name of the method using the terms "copy", "alloc," or "new"
Logged
Pages: [1] Go Up
Print
Jump to:



Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Entire forum contents (c) 2009 classroomM.com. All rights reserved.