What's the difference between single and double quotes in Objective-C?
- by Alex Mcp
I'm working through a book exercise to generate some random serial number, and here's my function:
NSString *randomSerialNumber = [NSString stringWithFormat:@"%c%c%c%c%c",
'0' + random() % 10,
'A' + random() % 26,
'0' + random() % 10,
'A' + random() % 26,
'0' + random() % 10];
This works and has an output like: 2J6X7. But before, the 0s and As I had wrapped in double quotes, and an example output was 11764iÒ˜. What did I do wrong my first time around, and why did using single quotes fix it?