Jump to content

Help with array


2 posts in this topic

Recommended Posts

I have an array and I need to be able to copy its elements into a string.

 

NSString* myString = [NSString string];

char *answers[] = {

 

"Answer one",

"Answer two",

"Answer three" };

 

 

myString = answers[2];

 

label.text = myString;

 

The assignment of answers[3] to myString fails with a warning about an incompatible pointer type.

 

I was able to load my string like this: myString = @"Answer three";

 

I'm new to Objective C and last used C about 20 years ago. I've ordered Programming in Objective-C 2.0 (2nd Edition) and K&R's C Programming Language, but would appreciate some help in the meantime. My environment is Leopard and XCode 3.1.2 and my target is the iPhone/iTouch.

 

Thanks!

Link to comment
Share on other sites

 Share

×
×
  • Create New...