2

i found something like this was not expected

code

NSString *strCrown2 = @"T-#-B-DAC";

when i put break point there and check i found like below image

enter image description here

There is \x , it is not part of string

in console it is displaying T-#-B-DAC it is correct

my question is why \x is showing there ?

Prashant Tukadiya
  • 15,838
  • 4
  • 62
  • 98
  • I dont think that create any problem the po output is : correct that what you want – Nitin Gohel Apr 26 '16 at 07:59
  • @Mile Alter did you find any solution for this, I am facing similar issue and none of the answers here worked for me. – Milan Gupta Jul 29 '16 at 10:24
  • @MilanGupta in my case the problem is ,when i copy that text one hidden character also copied don't know how , i was not able to eliminate that with character set , solution : i typed text with keyboard and that works – Prashant Tukadiya Jul 30 '16 at 03:45

5 Answers5

1

Because # is for prefix of hex color

You can solve it by escape sequence

NSString *strCrown2 = @"T-\#-B-DAC";

strCrown2 = [strCrown2 stringByReplacingOccurrencesOfString:@"\#" withString:@"200"];//outout:@"T-200-B-DAC"

You can also only # not considering '\x' value like the below

 NSString *strCrown2 = @"T-#-B-DAC";
 strCrown2 = [strCrown2 stringByReplacingOccurrencesOfString:@"#" withString:@"200"];//outout:@"T-200-B-DAC"
Jamil
  • 2,977
  • 1
  • 13
  • 23
1

Edit :- I got your solution , you can't able to see but , try to delete "-" before # , it will first delete one space and then your "-" will be deleted. so, it will take one white space before #

And, According to apple document , check

NSRegularExpression

enter image description here

so, it will take white space before # just delete it once you will get desire output when you debug.

I hope this info will be helpful for you.

Edit :-

enter image description here

Write this in your x-code ,

NSString *strCrown2 = @"T-#-B-DAC";
Badal Shah
  • 7,541
  • 2
  • 30
  • 65
0

The \x is used for hexadecimal representation of a number.

You can follow link for string specifiers here

Mahendra
  • 8,448
  • 3
  • 33
  • 56
0

I have tried same string, may be you are not using x-code 7. I am not getting as like you , i think it is showing the unicode string. you can add the string in the info.plist . it will work.

enter image description here

Abhishek Mishra
  • 1,625
  • 16
  • 32
0

I solved it

Before

enter image description here

After

enter image description here

i don't know how both string looks same

Prashant Tukadiya
  • 15,838
  • 4
  • 62
  • 98