NSCFString Vs NSString String Comparison in Conditional Statements
Recently I have come across with a problem of string (NSString/NSCFString) comparison in a IF Condition.
I got a solution and check the solution below.
I have declared a Variable of type NSString and tried to retrieve some value to this which is returning NSCFString.
NSString *retVal;
retVal = //Some routine which will return NSCFString.
You will not get any build and runtime errors as the variable is "NSString" and return value is some thing different "NSCFString" but if you use this returned value in conditional statements it will not work.
For suppose retVal is "Enabled".
if(retVal == @"Enabled"){
//Enabled }
else {
//Disabled }
In the above case even retVal is "Enabled" it will not go to the Enabled Section
To resolve the above issue we need to follow the following code snippet,
if([retVal isEqualToString: @"Enabled"]){
//Enabled}
else {
//Disabled]; }
I got a solution and check the solution below.
I have declared a Variable of type NSString and tried to retrieve some value to this which is returning NSCFString.
NSString *retVal;
retVal = //Some routine which will return NSCFString.
You will not get any build and runtime errors as the variable is "NSString" and return value is some thing different "NSCFString" but if you use this returned value in conditional statements it will not work.
For suppose retVal is "Enabled".
if(retVal == @"Enabled"){
//Enabled }
else {
//Disabled }
In the above case even retVal is "Enabled" it will not go to the Enabled Section
To resolve the above issue we need to follow the following code snippet,
if([retVal isEqualToString: @"Enabled"]){
//Enabled}
else {
//Disabled]; }
I do agree with all the ideas you’ve introduced on your post. They are really convincing and will certainly work. Still, the posts are very quick for newbies. May just you please extend them a bit from subsequent time? Thanks for the post. smm panel youtube
ReplyDeleteI think this is one of the most important information for me. And i am glad reading your article. But wanna remark on some general things, The website style is wonderful, the articles is really excellent : D. Good job, cheers Get well soon
ReplyDeleteDD10D6E2D8
ReplyDeletetakipçi satın al
Para Kazandıran Oyunlar
Garantili Takipçi
Alışveriş Siteleri
Instagram Takipçi Arttırma
992ED74941
ReplyDeletekiralık hacker
hacker arıyorum
kiralık hacker
hacker arıyorum
belek
0DC095AD29
ReplyDeleteGörüntülü Seks
Sanal Seks
Whatsapp Görüntülü Show Güvenilir
ReplyDeleteWhen exploring different printing techniques, many artists are turning to innovative solutions to enhance their designs. One popular choice is dtf transfer film, which offers vibrant colors and durability. This method allows for detailed and high-quality prints that stand out on various surfaces. By incorporating dtf transfer film, creators can achieve professional results with ease. Overall, it has become a go-to option for those seeking reliable and eye-catching printing options.
ReplyDeleteHayatın karmaşasında kendimize yeni ufuklar açmak için farklı kitaplar keşfetmek oldukça önemli. Bu nedenle, kitap önerileri sayesinde hem yeni bilgiler edinebilir hem de farklı bakış açıları kazanabiliriz. Okumak, insanın hayal gücünü geliştirirken aynı zamanda yaşam deneyimlerini zenginleştirir. Bu nedenle, kitaplara zaman ayırmak, kişisel gelişimimize büyük katkı sağlar.