Re: NSString initWithFormat and stringWith

2009-05-28 Thread Bill Bumgarner
On May 28, 2009, at 8:39 AM, Jesper Storm Bache wrote: Does your latest statement mean that the following (from http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/Tasks/loading.html#//apple_ref/doc/uid/20001127-124675 ) is incorrect/obsolete information: "You can unloa

Re: NSString initWithFormat and stringWith

2009-05-28 Thread Jesper Storm Bache
Does your latest statement mean that the following (from http://developer.apple.com/documentation/CoreFoundation/Conceptual/CFBundles/Tasks/loading.html#/ /apple_ref/doc/uid/20001127-124675) is incorrect/obsolete information: "You can unload the contents of a CFBundle object using CFBundleUnlo

Re: NSString initWithFormat and stringWith

2009-05-28 Thread Bill Bumgarner
On May 28, 2009, at 7:52 AM, Andy Lee wrote: On Wednesday, May 27, 2009, at 11:23PM, "Bill Bumgarner" wrote: If you find something that is causing a bundle with Objective-C code to be unloaded, please file a bug via http://bugreport.apple.com/. It isn't supported and the number of edge cases

Re: NSString initWithFormat and stringWith

2009-05-28 Thread Andy Lee
On Wednesday, May 27, 2009, at 11:23PM, "Bill Bumgarner" wrote: >On May 27, 2009, at 8:20 PM, Andy Lee wrote: >> I just noticed an earlier message in this thread that points out >> that stringWithString: does in fact do the same optimization as - >> copy for constant strings. So the approach i

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Bill Bumgarner
On May 27, 2009, at 8:20 PM, Andy Lee wrote: I just noticed an earlier message in this thread that points out that stringWithString: does in fact do the same optimization as - copy for constant strings. So the approach in Apple's sample code does not protect from the bundle unloading problem

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Andy Lee
I just noticed an earlier message in this thread that points out that stringWithString: does in fact do the same optimization as -copy for constant strings. So the approach in Apple's sample code does not protect from the bundle unloading problem. Aside from the OTHER_CFLAGS approach Jesp

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Jesper Storm Bache
Assuming that NSString may be using CFStrings, then the issue may be related to const strings. See information regarding "OTHER_CFLAGS = -fno-constant-cfstrings" The basic issue is that when constant cfstrings is enabled, then the string may be put into the TEXT segment and you end up passing

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Andy Lee
On Wednesday, May 27, 2009, at 11:48AM, "Michael Ash" wrote: >This may seem nitpicky but I see a lot of newbies writing code just >like this. Their code is filled with stringWithString: calls for >absolutely no purpose, so I want to discourage that sort of thing. Just for grins, I searched for c

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Alex Curylo
On 27-May-09, at 8:41 AM, cocoa-dev-requ...@lists.apple.com wrote: Well I am trying to find where is my mistake, since sometimes my application crashes and I am quite (99.9%) sure that I am releasing a object that shouldn't be. Any ideas how to find such a bug? As long as the crashes happen

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Ignacio Enriquez
Thanks to all! NSZombiesEnabled YES Is really helpfull, now I now where to start!;) I wish I would have known this before. Cheers On Thu, May 28, 2009 at 12:38 AM, Bill Bumgarner wrote: > On May 27, 2009, at 8:34 AM, Ignacio Enriquez wrote: >> >> And regarding why use retainCount? >> Well I am

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Michael Ash
On Wed, May 27, 2009 at 11:05 AM, Erik Buck wrote: > As an alternative, use > NSString *string1 = [[NSString stringWithString:@"myFirstString"] retain]; > or NSString *string2 = [[NSString alloc] initWithString:@"mySecondString"]; > or NSString *string3 = [@"myThirdString" copy]; However you shou

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Bill Bumgarner
On May 27, 2009, at 8:34 AM, Ignacio Enriquez wrote: And regarding why use retainCount? Well I am trying to find where is my mistake, since sometimes my application crashes and I am quite (99.9%) sure that I am releasing a object that shouldn't be. Using -retainCount won't help you; a temptin

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Ignacio Enriquez
First: I just realized that one of my statements was incorrect; NSString *string2 = [[NSString alloc] initWithFormat:@"mySecondString"]; does not make string2 retainCount to be 2147483647, it only becomes 2147483647 when inserting @"" instead of @"mySecondString" And regarding why use retainC

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Sherm Pendley
On Wed, May 27, 2009 at 9:59 AM, Ignacio Enriquez wrote: > > 1.- What is the difference between string1 and string2? where > NSString *string1 = [NSString stringWithFormat:@"myFirstString"]; > NSString *string2 = [[NSString alloc] initWithFormat:@"mySecondString"]; You own string2 and must rele

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Erik Buck
Don't ever write either of the following lines: > NSString *string1 = [NSString stringWithFormat:@"myFirstString"]; > NSString *string2 = [[NSString alloc] initWithFormat:@"mySecondString"]; the WithFormat methods parse the argument string. If your argument string contains any '%' character

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Dave DeLong
Hi Ignacio, I just ran a simple test, pasted below: NSString * one = [NSString stringWithString:@"Hello"]; NSString * two = [[NSString alloc] initWithString:@"Hello"]; NSLog(@"%X, %X, %X", one, two, @"Hello"); What you see logged is that the three strings point to the sa

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Graham Cox
On 27/05/2009, at 11:59 PM, Ignacio Enriquez wrote: I have a basic question regarding Class methods and instance methods and memory allocation. (this is in iPhone OS 3.0 beta 5) 1.- What is the difference between string1 and string2? where NSString *string1 = [NSString stringWithFormat:@"myFir

Re: NSString initWithFormat and stringWith

2009-05-27 Thread Jesper Storm Bache
On May 27, 2009, at 6:59 AM, Ignacio Enriquez wrote: Hi. I have a basic question regarding Class methods and instance methods and memory allocation. (this is in iPhone OS 3.0 beta 5) 1.- What is the difference between string1 and string2? where NSString *string1 = [NSString stringWithFormat:@"my

NSString initWithFormat and stringWith

2009-05-27 Thread Ignacio Enriquez
Hi. I have a basic question regarding Class methods and instance methods and memory allocation. (this is in iPhone OS 3.0 beta 5) 1.- What is the difference between string1 and string2? where NSString *string1 = [NSString stringWithFormat:@"myFirstString"]; NSString *string2 = [[NSString alloc] in