Convert QString to NSString*
I'm working on an iOS app. I need to convert a QString to a NSString* but I can't figure out how it works. The following code produces a NSException:
QString qs = "test";
NSString* nss = qs.toNSString();
NSLog(@"qs to ns: %@", [NSString nss]);
@catch (NSException *theException)
NSLog(@"An exception occurred: %@", theException.name);
NSLog(@"Here are some details: %@", theException.reason);
2016-07-25 13:58:13.676 MyApp[3832:1414942] +[NSString nss]: unrecognized selector sent to class 0x3b5b42dc
2016-07-25 13:58:13.677 MyApp[3832:1414942] An exception occurred: NSInvalidArgumentException
2016-07-25 13:58:13.677 MyApp[3832:1414942] Here are some details: +[NSString nss]: unrecognized selector sent to class 0x3b5b42dc
What do I miss?
Thank you in advance.
This post is deleted!
In particular, look at the "Getting C Strings" portion.
If you want to log
nsswhy not use
NSLog(@"qs to ns: %@", nss);?
Thank you for your replies.
@SGaist you're right - the string conversion is correct but the NSLog() call was wrong.
I should take a look at the objective C basics.