• 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
Dynamic NSString Array Help?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Dynamic NSString Array Help?


  • Subject: Dynamic NSString Array Help?
  • From: Quentin Whitmyer <email@hidden>
  • Date: Sat, 19 Apr 2003 17:31:28 -0400

Hello,

I am trying to find a way to create a Dynamic Array of NSStrings. I know I could use the NSArray object. But i am trying to do it another way.

I know that I can create a static array of NSStrings

int i;
NSString *theArray[100];

for(i =0; i < 100; i++)
{
theArray[i] = [[NSString alloc] initWithString: @"this is a test"];
NSLog(@"%@", values[1]);
}

This seems to work.

However when I try

int i;
NSString *theArray;

theArray = (NSString *) malloc(sizeof(NSString) * 100);

for(i =0; i < 100; i++)
{
theArray[i] = [[NSString alloc] initWithString: @"this is a test"];
NSLog(@"%@", values[1]);
}

This Fails. I get this error when I try to compile it:
incompatible types in assignment

I have tried this many different ways. The only way I have gotten it to work is to change "theArray" to an "int". I know that changing the type of "theArray" is not the proper way to achieve the results I am looking for.

Thanks for your help in advance.
-Q-
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: Dynamic NSString Array Help?
      • From: Julien Jalon <email@hidden>
  • Prev by Date: Re: A pie analyzer
  • Next by Date: Tableview in Utility Panel
  • Previous by thread: Prefix for statfs.f_fstypename
  • Next by thread: Re: Dynamic NSString Array Help?
  • Index(es):
    • Date
    • Thread