Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > Mac OS X Development Forums > Objective-C, Python, Ruby Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-07-2009, 12:35 PM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 80
itsaboutcode is on a distinguished road
Default NSString retain Count

Hi,

Just couple of days i was working on a project and i have to see what is retain count of a string.

But it always return me "2147483647", Why it is so?

Check out this code to check it yourself.
PHP Code:
NSString *str = [[NSString allocinitWithString:@"Hello World"];
NSLog(@"String Retain Count: %i", [str retainCount]); 
So my question is why it is not returning 1 like other objects return, why i am getting "2147483647"

Thanks in advance.

Last edited by itsaboutcode; 09-07-2009 at 12:37 PM.
itsaboutcode is offline   Reply With Quote
Old 09-07-2009, 01:43 PM   #2 (permalink)
Coder for Life
 
Karl Kraft's Avatar
 
Join Date: Sep 2008
Location: Austin, TX
Posts: 76
Karl Kraft is on a distinguished road
Send a message via AIM to Karl Kraft
Default

Quote:
Originally Posted by itsaboutcode View Post
Hi,

Just couple of days i was working on a project and i have to see what is retain count of a string.

But it always return me "2147483647", Why it is so?
Because your string is not in the heap, but is a constant. A NSString made from a constant NSString is identical to the original NSString.

http://www.iphonedevsdk.com/forum/ma...count-1-a.html

Don’t use non mutable objects to understand leak detection

Equality vs Identity
Karl Kraft is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 458
13 members and 445 guests
Domele, Duncan C, Feldspar, MacBook MH, Objective Zero, patapple, peterwilli, pipposanta, PixelInteractive, Punkjumper, SLIC, taylor202, Today's Posts
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,694
Threads: 94,137
Posts: 402,950
Top Poster: BrianSlick (7,990)
Welcome to our newest member, peterwilli
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:03 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0