I have cpp const char* string
which contains " playlist"
characters.
I am trying to convert it into NSString
and I am getting "@(NULL)"
string.
Following are my steps to convert it.
string cppString = " playlist"; //Cpp data type
- I have one method where I am passing my cpp string like
NSString *str = [self charStringToString:cppString.c_str()];
and the method returns NSString
object after some operations:
+ (NSString *)charStringToString:(const char*)cppStringConst
{
if ( cppStringConst == NULL || cppStringConst == nullptr )
{
return @"";
}
NSString *outputString = [NSString stringWithFormat:@"%@", [NSString stringWithUTF8String:cppStringConst]];
if ( [outputString isEqualToString:@"(null)"] == YES )
{
//it should not come here if I am passing playlist
return @"";
}
return outputString;
}
Could anyone resolve my problem??