NSString *string = @"123"; char str[1024]; [string getCString: str maxLength: 1024 encoding: NSStringEncodingConversionAllowLossy];