-1

When I use this bit of code:

   NSMutableData *stringMutableData = [[_inputMessageField stringValue] dataUsingEncoding:NSUTF8StringEncoding];

I always get the warning:

Incompatible pointer types initializing 'NSMutableData *' with an expression of type 'NSData *'

However the code seems to work flawlessly. Could somebody explain to me why this message is showing up and how I would code it properly?

Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140

1 Answers1

1

In your code

[[_inputMessageField stringValue] dataUsingEncoding:NSUTF8StringEncoding]

returns NSData * .

While you are assigning it to MutableData.

You can change either of them to get no warning.

NSData *stringData  = [[_inputMessageField stringValue] dataUsingEncoding:NSUTF8StringEncoding];

or

NSMutableData *stringMutableData = [[[_inputMessageField stringValue] dataUsingEncoding:NSUTF8StringEncoding] mutableCopy];
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140