discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMutableString -initWithFormat appends to existing text


From: Mick Bert
Subject: NSMutableString -initWithFormat appends to existing text
Date: Wed, 18 Apr 2018 09:42:12 +0200

Hello.
Can I make question about how to use API, in this list?
I decided to use GNUstep for all the working activity where I have the
chance, just to practice my obj-c/gnustep experience.

Well, in a method I am using and re-using an object of
NSMutableString, so I create it once with +stringWithCapacity, an than
I initialize with -initWithFormat. Something like:

  NSMutableString *outmsg=[NSMutableString stringWithCapacity: 1000];
  outmsg=[outmsg initWithFormat: @"first: %@", [arr objectAtIndex: 0]];
  // use outmsg
  outmsg=[outmsg initWithFormat: @"second: %@", [arr objectAtIndex: 1]];
  // use outmsg
 outmsg=[outmsg initWithFormat: @"third: %@", [arr objectAtIndex: 2]];
  // use outmsg

What I observe is that every time I invoke -initWithFormat the text is
appended at the end of the existing string. Is it the right behavior
to expect? Am I doing something wrong?
--
Mick



reply via email to

[Prev in Thread] Current Thread [Next in Thread]