[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSString:stringWithFormat: Example? (OPENSTEPIFIED)
From: |
richard |
Subject: |
Re: NSString:stringWithFormat: Example? (OPENSTEPIFIED) |
Date: |
Fri, 29 Sep 2000 12:40:02 +0100 |
On Fri, 29 Sep 2000 11:50:39 +0200, jolly@jinx.de wrote:
>richard@brainstorm.co.uk wrote:
>>
>>#include <Foundation/Foundation.h>
>>main()
>>{
>> CREATE_AUTORELEASE_POOL(pool);
>> NSString *myString;
>>
>> myString = [NSString stringWithFormat: @"A C string '%s' and a number
>'%d'",
>> "hello", 42];
>> NSLog(@"Result is - @%", myString);
>> RELEASE(pool);
>>}
>>
>The above will only work on GNUSTEP not OPENSTEP - please keep in mind to be
>OPENSTEP compliant you
>have to use the common subset.
>
>CREATE_AUTORELEASE_POOL(pool);
>should be
>NSAutoreleasePool *myPool = [[AutoreleasePool alloc] init];
>
>and
>RELEASE(pool);
>should be
>[myPool release];
To be more accurate - you should define the macros when you are building on a
MacOS/OPENSTEP system. Otherwise your code loses the possibility of working
as efficiently with garbage collection under GNUstep.
Of course, if you are sure you will never want to use garbage collection
and/or you don't care about best possible performance, then using the retain
counting methods directly is fine.
Re: NSString:stringWithFormat: Example?, yun, 2000/09/29