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!

Converting char into NSString

I am having trouble converting arguments to NSString format for my Cocoa application. I start my application like so: open my.app –args a1 a2 I try to access the arguments like so: const char *h_pat

Converting NSString into const char

I have an String and i want to convert it into Const Char . I Had tried but it’s not Working NSString *str4 = [NSString stringWithUTF8String:character];

Converting NSString to Char Array

I have an array full of NSString’s in hex and what to create a char array from them. I’m not sure how this can be done. So I have an array NSArray *myArray = [NSArray arrayWithObjects:@0xAA, @0xBB

Converting char array into NSString object

As per my assignment I have to take in input from a user via a console to be used with NSString. At the moment I have char* name[100]; // declaring char array NSString* firstName; // declaring the NS

When converting a NSString to a char* using UTF8String, how to retain it?

When converting a NSString to a char* using UTF8String, how to retain it? According to the following link, when you use UTF8String the returned char* is pretty much autoreleased, so it won’t last beyo

Casting or converting a char to an NSString in Objective C

Simple question… How do I convert a char to an NSString in Objective C? Not a c-string, just a simple char c = ‘a’.

Cannot find file when converting NSString to char*

So I have a platform independent API that loads a file, it takes a char* as a value. I wrote some test code in the GetResource function that used a string literal and it worked fine. However when I co

NSString to char[]?

struct DATA { unsigned char USERNAME[32]; }; i want copy a NSString to struct DATA.USERNAME , how to do it ?

Convert char to NSString [duplicate]

Possible Duplicate: Convert from char* to NSString? I have char myChar = ‘r’ How do I convert it to a NSString? NSString* string = @r;

convert char * to NSString

I want to show the char* in the UITextField situation: char *data; char *name=data+6; txtName.text=[[NSString alloc] initWithCString:name encoding:NSUTF8StringEncoding]; but I am not getting the cor

Answers

Simple to transfer

const char *cfilename=[stringobject UTF8String];