nscfstring

NSString or NSCFString in xcode?

混江龙づ霸主 提交于 2019-12-07 18:46:17
问题 I m taking a NSMutabledictionary object in NSString like this : NSString *state=[d valueForKey:@"State"]; Now sometimes state may be null and sometimes filled with text.So Im comparing it.While comparing state becomes NSString sometimes and NSCFString othertimes..So unable to get the desired result.. if([state isEqualToString@""]) { //do something } else { //do something } So while comparing it is returning nil sometimes.So immediately jumping into the else block. I need a standard way to

Convert NSCFString to NSString

孤街醉人 提交于 2019-12-07 04:39:37
问题 I am getting a dictionary from server myDictionary = { "rank":"1", "color":"red", "position":"middle" } Now I want to check the value of key "position" in if condition I am doing it like this if ([[myDictionary valueForKey:@"position"] isEqualToString:@"middle"]) { //do Some stuff } else{ //do some other stuff } but data type of [myDictionary valueForKey:@"position"] is _NSCFString , so it does not compare value properly and never goes in if loop even the value is correct. how do I convert it

NSString or NSCFString in xcode?

雨燕双飞 提交于 2019-12-06 06:12:37
I m taking a NSMutabledictionary object in NSString like this : NSString *state=[d valueForKey:@"State"]; Now sometimes state may be null and sometimes filled with text.So Im comparing it.While comparing state becomes NSString sometimes and NSCFString othertimes..So unable to get the desired result.. if([state isEqualToString@""]) { //do something } else { //do something } So while comparing it is returning nil sometimes.So immediately jumping into the else block. I need a standard way to compare if the state is empty whether it is a NSString or NSCFString ... How can I do it? If you're unable