Mike
Mike

Reputation: 301

NSString pointer type warning

I need to get a string value from an NSArray to populate a pop-up button with. This code populates the button, but I have a warning "Incompatible pointer types assigning to 'NSMutableString * _strong' from 'NSString *'.

for (NSObject * obj in availablePorts)
{
  result = [obj description];
  [portsButton addItemWithTitle:((NSString *)result)];
}

Upvotes: 1

Views: 1332

Answers (1)

Sebastian
Sebastian

Reputation: 7710

result is a NSMutableString*. Your are trying to assign a pointer to NSString to a variable of type pointer to NSMutableString. Either change your declaration of result, or assign using [[obj description] mutableCopy] if you need an NSMutableString

Upvotes: 3

Related Questions