In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "what is JSONModel", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn this article "what is JSONModel?"
JSONModel is an open source library. Using this library, you can easily solve problems such as changing dictionaries to models and solve key-value pairs that do not match exactly (that is, when KVC assignment cannot be used).
[size=1em] first define a class that inherits JSONModel
[size=1em] / / this class JuBaModel is the base class of the model, and later models will inherit JuBaModel (the name of this class is prefixed with the name of my project, and readers can define it themselves)
[size=1em] # import
[size=1em] # import "JSONModel.h"
[size=1em] @ interface JuBaModel: JSONModel
[size=1em] @ end
[size=1em] # import "JuBaModel.h"
[size=1em] @ implementation JuBaModel
[size=1em] / * this is the method of JSONModel. The purpose is to convert the _ mode named to the Camel named method.
[size=1em] [size=1em] because the server-side naming words are separated by _, and OC is named in Camel nomenclature.
[size=1em] [size=1em] for example: hello_word in JSON and helloWord should be defined in the model (so that it can be matched automatically)
[size=1em] [size=1em] * /
[size=1em] + (JSONKeyMapper *) keyMapper {
[size=1em] [size=1em] return [size=1em] [JSONKeyMapper mapperFromUnderscoreCaseToCamelCase]
[size=1em]}
[size=1em] / * this ensures that the attributes in JSON are selectable
[size=1em] [size=1em] that is, if there are more attributes in Model, it doesn't matter if you have fewer attributes.
[size=1em] [size=1em] when assigning values to a model with a dictionary, JSONModel can always find an one-to-one correspondence
[size=1em] [size=1em] for example, there is a key hell0_word username password in JSON and only username password in the model
[size=1em] [size=1em] then when you assign a value automatically, the key corresponding to username password will be assigned automatically, and KVC cannot be used in this case.
[size=1em] [size=1em] * /
[size=1em] + ([size=1em] Bool [size = 1em]) propertyIsOptional: (NSString *) propertyName {
[size=1em] [size=1em] return [size=1em] YES
[size=1em]}
@ end
The above is all the content of this article "what is JSONModel?" thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.