Amazon.com Widgets Issue with Program 17.1
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 24, 2013, 12:34:15 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
| |-+  Chapter Study
| | |-+  Chapter 17 - Memory Management
| | | |-+  Issue with Program 17.1
Pages: [1]   Go Down
Print
Author Topic: Issue with Program 17.1  (Read 454 times)
darren
Newbie
*
Posts: 1


Email




« on: August 01, 2011, 12:46:02 AM »

Hi folks,

I am attempting to run the first program in chapter 17.  However, the values for the retain counts appear to be off:

2011-08-01 00:35:16.004 Learnin[16956:707] myInt retain count = 7fffffffffffffff
2011-08-01 00:35:16.005 Learnin[16956:707] after adding to array = 7fffffffffffffff
2011-08-01 00:35:16.006 Learnin[16956:707] after assignment to myInt2 = 7fffffffffffffff
2011-08-01 00:35:16.007 Learnin[16956:707] myInt after retain = 7fffffffffffffff
2011-08-01 00:35:16.007 Learnin[16956:707] myInt2 after retain = 7fffffffffffffff
2011-08-01 00:35:16.008 Learnin[16956:707] myInt after release = 7fffffffffffffff
2011-08-01 00:35:16.008 Learnin[16956:707] after removal from array = 7fffffffffffffff

I am running this on a recent MacBook Pro with Lion, so I am guessing this is a 64bit issue of some kind.  What would be the proper way to print these out?

Also, I think there is a typo in the creation of the NSNumber object:

    NSNumber *myInt = [[NSNumber alloc: initWithInteger: 100];

Shouldn't that be:

    NSNumber *myInt = [NSNumber numberWithInt: 100];

or am I missing something?

Thanks.
Logged
skochan
Administrator
Hero Member
*****
Posts: 3104







« Reply #1 on: August 01, 2011, 12:42:53 PM »

Hmm, I just discovered this problem.  It appears as though Apple has made a change to the way retain counts are kept for NSNumber objects.  It looks as though they're all set to that value--meaning they can never be released.  I'll have to make a note of that.

As for your second question, you can do [[NSNumber alloc] initWithInteger: 100] or [NSNumber numberWithInt: 100]

Cheers,

Steve
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.