jeffelkins Posted January 6, 2009 Share Posted January 6, 2009 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 More sharing options...
stroke Posted January 9, 2009 Share Posted January 9, 2009 myString = [NSString stringWithCString:answers[2] encoding:NSASCIIStringEncoding]; Link to comment Share on other sites More sharing options...
Recommended Posts