Ok, I know this is a very basic question, but my head is swimming in NSString vs C string
nonsense.
Basically I have a NSString the just contain 1 character for example the letter D
How do I take that 1 character NSString and assign it to a variable of char
So I have…
char mychar;
NSString *myMode = [[NSString alloc] initWithFormat:@"%@",[array objectAtIndex:0]];
//myMode ends up hold the letter D. How do I get it into mychar??
Thanks for any help.
Use
characterAtIndex:. However, this returns a Unicode character (unichar). If you know that the character is definitely ASCII, you can safely cast it to achar: