Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting an NSString* to char?

How can I convert a NSString* into a char?

EDIT: Thanks to Vladimir for getting me there!

NSString *myString = @"HelloWorld";
const char *stringAsChar = [myString cStringUsingEncoding:[NSString defaultCStringEncoding]];

Hope this helps someone in the future!

like image 714
ingh.am Avatar asked Jun 08 '10 10:06

ingh.am


People also ask

What is NSString objective c?

Like NSNumber, NSString is also immutable type. It's used to represent text in Objective-C. NSString provides built-in support for Unicode, which means that we can include UTF-8 characters directly in string literals.

What is NSString in swift?

A static, plain-text Unicode string object that bridges to String ; use NSString when you need reference semantics or other Foundation-specific behavior.


1 Answers

Simple to transfer

const char *cfilename=[stringobject UTF8String];
like image 161
GameLoading Avatar answered Sep 25 '22 23:09

GameLoading