There are 2 problems in your code:
1) "char datechar ..." is a one-character character that will contain only one char / byte, and will not contain the entire array that you create from your date / string object. Therefore, your string must have (*) in front of the variable in order to store several characters, and not just one.
2) After the above correction, you will still receive a warning about (char *) vs (const char *), so you will need to "distinguish" because they technically match the results. Change the line:
char datechar = [date UTF8String];
in
char *datechar = (char *)[date UTF8String];
The notification (char *) after the = sign tells the compiler that the expression will return (char *), not the default (const char *).
I know that you already noted the answer earlier, but I thought I could do my part to explain the problems and how to fix it in more detail.
Hope this helps.
Regards Haider
Heider sati
source share