ios - JSONModel incorrectly converting 'T' to '0' on 32-bit devices -


I am facing an interesting issue related to any string BOOL . I am passing a string value t in JSON and need to convert it to a BOOL.

Using JSONModel, the conversion works on the 64-bit device, correctly converts from 1 to one (obviously some magic is running here). However, on 32-bit devices, T has incorrectly changed to 0. I am having trouble finding out why this is happening and how to fix it.

I know that JSONValueTransformer BOOLFromNSString is called 32-bit device, and does not return any returns, but it does not return 64-bit devices Is not called for.

Will anyone have 32-bit / 64-bit architecture and why? How can this be fixed so that the correct BOOL value is returned to 32-bit and 64-bit devices?

The following is the BOOLFromNSString method in the project you linked: < / P>

  - (NSNumber *) BOOLFromNSString: (NSString *) string {if (string! = Zero & amp; ([string caseInsensitiveCompare: @ "right"] == NSOrderedSame || [ String caseInsensitiveCompare: @ "yes"] == NSOrderedSame) {return [NSNumber numberWithBool: Yes]; } Return [NSNumber Number Vithubles: ([String Intuue]] == 0) No: Yes]; }  

This means that it is expected to return to the following case-sensitive values: true , Yes , [Any number that is not 0] .

This Yes for T gives magic on any platform, not "right". You should use one of the values ​​expected


Edit :. Your subclass:

  #import "JSONModelTransformations / JSONValueTransformer.h" @interface MyParser: JSONValueTransformer @end @implementation MyParser - (NSNumber *) BOOLFromNSString: (NSString *) string {if (! String = Null & amp; [String caseInsensitiveCompare: @ "T"] == NSOrderedSame) {Return [NSNumber numberWithBool: Yes]; } Return [Super BOOLFromNSString: string]; } @end  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -