• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSMutableString, NSMutableArray, scrambledString
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableString, NSMutableArray, scrambledString


  • Subject: Re: NSMutableString, NSMutableArray, scrambledString
  • From: Peter Ammon <email@hidden>
  • Date: Tue, 10 Jul 2001 10:04:38 -0700

on 7/10/01 7:25 AM, Michel Haver at email@hidden wrote:

[...]
>
> Why can't these NSMutableString declarations be placed in the Controller.h?
>
> NSMutableString* inString = [NSMutableString stringWithString:
> @"teststring"];
> NSMutableString* tempString = [NSMutableString string];
> NSMutableString* outString = [NSMutableString string];

Those are not declarations, those are definitions, complete with
initializations. As you surmised, you can't initialize anything in the
@interface declaration. It must all go in an initialization method, e.g.
init.

>
> What is the proper declaration if you want to place these NSMutableStrings
> in the Controller.h?
>

It can't be done, and that's probably a good thing. When would those
messages get sent, for example?

>
> I want to use an NSMutableArray to store several strings
>
> NSMutableArray *scrambledPlayStringArray;
> scrambledplayStringArray = [[ NSMutableArray alloc ] initWithCapacity: 10 ];
>
> Then the question is how can I add for example a outString to the
> scrambledPlayStringArray?
>
> [ scrambledPlayStringArray insertString: outString atIndex: 0 ]; doesn9t
> work.
>
> If you test that you get the error message:
> Jul 10 15:56:13 RandomStringTester[1338] *** -[NSCFArray
> insertString:atIndex:]: selector not recognized
> Jul 10 15:56:13 RandomStringTester[1338] *** -[NSCFArray
> insertString:atIndex:]: selector not recognized
>
> What is the proper selector?

It's in the documentation and the headers. insertObject:atIndex:. But
you'll probably prefer the addObject: method instead.

>
> Or must I use NSMutableDictionary instead?

No.

-Peter


References: 
 >NSMutableString, NSMutableArray, scrambledString (From: Michel Haver <email@hidden>)

  • Prev by Date: Re: NSThread question
  • Next by Date: Re: NSMenu in small PopUp buttons
  • Previous by thread: NSMutableString, NSMutableArray, scrambledString
  • Next by thread: Re: NSMutableString, NSMutableArray, scrambledString
  • Index(es):
    • Date
    • Thread