[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: NSString:stringWithFormat: Example? (OPENSTEPIFIED)
From: |
Pascal J. Bourguignon |
Subject: |
Re: NSString:stringWithFormat: Example? (OPENSTEPIFIED) |
Date: |
Fri, 29 Sep 2000 19:06:17 +0200 (CEST) |
> From: Patrick Stein <jolly@jinx.de>
> Date: Fri, 29 Sep 2000 11:50:39 +0200
>
> 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];
>
>
>
> keep on moving - jolly
Right. That's why, GNUstep extensions should appear only in separate
headers and sources, that may be compiled in a separated library to be
used on the other OpenStep implementation when we port GNUstep
applications.
Then:
#include <Foundation/Foundation.h>
#include <GNUstep/GSAutoreleasePool.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);
}
would be correct and compilable on any OpenStep implementation.
--
__Pascal Bourguignon__ PGP Key ID: 0xEF5E9966
mailto:pjb@imaginet.fr PGP fingerprint: 00 F5 7B DB CA 51 8A AD 04 5B
http://www.imaginet.fr/~pjb/ 6C DE 32 60 16 8E EF 5E 99 66
() Join the ASCII ribbon campaign against html email and Microsoft attachments.
/\ Software patents are endangering the computer industry all around the world.
Join the LPF: http://lpf.ai.mit.edu/ http://petition.eurolinux.org/
Re: NSString:stringWithFormat: Example?, yun, 2000/09/29