Search code examples
iphonexcodensstringnsdataincompatibility

Declare as NSString but Xcode treat as NSdata & received incompatible passing


I'm trying to pass an NSString address object to a UILabel text, but I received a warning from XCode compiler about incompatible pointer, as shown in the screen shot below:

incompatible pointer type warning - screenshot

And from the screen shot below you can see that my address object is declared as a NSString.

property type - screenshot

I had try displaying my NSString with:

    NSLog(@"%@",[[LocationData objectAtIndex:rowDisplay] address]);

and it works without any incompatible pointer error. Can anyone please help? I have done some researching but I still can't find any solution.

My address is an object which gets stored into an NSArray. The address format is the always the same, for example "542 W 112 St New York NY 10025".

Thanks.


Solution

  • there is many follow up questions with your question. However, you said, you can show with :

    NSLog(@"%@",[[LocationData objectAtIndex:rowDisplay] address]);
    

    so why not use this into UILabel :

    self.displayAddress.text =  [NSString stringWithFormat:@"%@"[[LocationData objectAtIndex:rowDisplay] address]];
    

    PS: please don't use image for 1 line of code. i have to retype your code here...