5

For the following line of code I am getting the error below:

for (UILabel *label in labels) {
    label.text = label.tag - 100 > someMutableString.length ? "" : "*";
}

The error states:

Implicit conversion of a non-Objective-C pointer type 'char *' to 'NSString *' is disallowed with ARC

My variable "someMutableString" is of type NSMutableString.

How do I fix in my particular case?

motionpotion
  • 2,656
  • 6
  • 42
  • 60

2 Answers2

12

The problem is that your string literals are "" and "*" which are both C-style strings (const char*). So the type of the right hand side of the assignment is also const char*. You are assigning to the text property of a UILabel, which takes an NSString.

Use @"" and @"*" instead.

Ken Thomases
  • 88,520
  • 7
  • 116
  • 154
  • that was it. Hopefully it helps somebody else too as when I search I didn't find this type of example associated with that error. – motionpotion Oct 23 '14 at 08:32
2
char *text = "a"

NSString *message = [NSString stringWithFormat:@"%s",text];

Cheers :)

Haseeb Javed
  • 1,769
  • 17
  • 20