Dynamic NSString Array Help?
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.