runtime store example - blackberry

Can any one give me a example of how to use the runtime store in blackberry?
I get the data from xml, shown below.
Can any one give me sample code to store the following node data into the runtime store and access these values in other classes?
<upcomingmeeting id="2">
<starttime>02:00pm </starttime>
<companyname>Qtech Software</companyname>
<meetingtype>New Agent</meetingtype>
<meetingwith>
<person>Yogesh</person>
<person>Mahesh </person>
<person>Ganesh </person>
</meetingwith>
<meetingnote>
<information>Yogesh good</information>
<information>Yogesh 1 bad</information>
</meetingnote>
</upcomingmeeting>
Thanks in advance

Read the article Storing objects nonpersistently carefully.
Following two sections of the above article will show how to store a String object on RuntimeStore and retrieve the object later.
Code sample: Storing a String in the runtime store
Code sample: Getting a stored String from the runtime store

You need to learn parsing XML first
Follow this link that how can you parse a XML from Http Request.
http://stackoverflow.com/questions/11901822/xml-parsing-using-sax-for-blackberry/11914662#11914662
While parsing XML you can parse it data to a Vector , Create this Vector in a seperate class by which you can access its value to any other class too.

Related

How to access object field in qaf step from stored variable

In my previous question I was looking for a way to access and store return value of the function in qaf step. I was provided with the following:
When create new user using "{'name':'user1','password':'user123'}"
And store into 'newUser'
Then system should have user '${newUser}'
Now, I'd like to know how to get value from object/collection stored.
If it is a simple object named newUser which has field Id. How would I pass Id on next step?
And, if return is List, how to get by index from stored list?
Resolved issue on my own. If anyone faces same unknowns, here is how I solved it.
For requirements to work around response data, parsing same stored objects in properties by specific fields or collecting data from other structures such as Maps or Lists, create common functions with #QAFTestStep annotation to get data for class member name, map by key or list by index and so on... Add those in common steps and then write stepname text in gherkin format with parameters specified. Let me know if someone needs help, always ready to help out...

Save a large JSON to Realm using Swift 3

I have a JSON with more or less 75 keys.
I need to receive this JSON and store offline it using Realm.
I do not want to iterate through the keys, since I've heard that there are ways to save a large JSON using a few lines. How can I do this?
EDIT:
My JSON (
I saved on a server away because it's too big)
http://myjson.com/i7e6l
There is no easy, one liner to parse the JSON and store it in Realm, since each JSON response is unique and no framework can have explicit knowledge about the structure of your JSON response without you giving some information to this framework about your JSON.
You will need to write some code either to parse the response or to make a mapping between your JSON response's fields and the properties of your Realm object. If you choose the latter solution, you can use Alamofire Object Mapper to do the JSON parsing automatically, but even then you have to write code for the mapping.

Different response on Console and infoView in ObjectiveC

I have to show the response with same order as I have received from my backend team.
But the response sequence is getting changed on extracting the values from Dictionary and array.
Please check the attached screenshot and suggest .
On extracting , I am getting 7703 but I need 5599 for showing the same position as in my website and in my application
Dictionary is not an ordered collection. You should create custom model class and use array of models.
You can use famous third party https://github.com/jsonmodel/jsonmodel
for mapping json to array of models.
Or you can sort dictionary keys (dict.allKeys) or values (dict.allValues)

CoreData and the "Allows External Storage" option

I'm doing a tutorial on CoreData and they talked about the "Allows External Storage" option. The documentation says "When enabled, Core Data heuristically decides on a per-value basis if it should save the data directly in the database or store a URI to a separate file which it manages for you. You cannot query based on the contents of a binary data property if you use this option." I understand the first part but I don't understand what they mean by "You cannot query based on the contents of a binary data property if you use this option". I feel this is important stuff, but I can't understand it. "You cannot query based on the contents of a binary data", what does that mean? I don't if it's my bad english or something but I can't figure it out.
The tutorial is "Core Data by Tutorials" from the Ray Wenderlich's tutorial book series. I highly recommend!
image the NSData you store is jpeg data with an exif header.
if you store the data inside the DB, you can use a predicate matching said exif data: e.g. something like (pseudo) "jpgedData CONTAINS author: dominik"
if you store it as a separate file, that query wouldn't work as the data isn't really inside the database
[note that this was explanatory pseudo code and I can't really think of a practical / useful example]
All that means is that if you enable that option for a property, you can't use that property in an NSPredicate when fetching objects. A fetch request is a query, and when you use a predicate you're fetching objects based on whether they match the predicate. That doesn't work if external storage is allowed for the property.
Ok I think I got it. Basically you can't use the image's raw meta data to look for a specific image, because you don't have access to the raw data. You only have access to the URI. Sounds logical and fair to me, since you could just extract the meta data, and store it in your CoreData model before saving the image as a transformable (if need be).

XML to Object Objective C

I'm trying to convert an XML response from Google to a custom object. My question is what's best to use as in NSMutableArray or NSDictionary when you have a multiple values in i.e. <category> or <title> and how to add them.
<category scheme="http://schemas.google.com/spreadsheets/2006"
term="http://schemas.google.com/spreadsheets/2006#spreadsheet"/>
<title type="text">nothing</title>
Marshaling XML onto a NSDictionary will work, however it can result in quite fragile and difficult to maintain code. Two reasons:
It will result - 'magic strings' when requesting data. Any change in this string will propagate throughout the code-base.
It will be difficult to read, and not exhibit the desirable self-documenting features of good OO.
Instead, its strongly recommended to map the XML of a service payload onto a use-case specific Objective-C object. This is aligned with the principle of contract-first development, meaning that any change to the service might only result in a change to this mapping onto the objective-C object.
A nice XML framework is RaptureXML
Create a category on the RXMLElement class and extract the required information. Then to use the element, just:
RXMLElement* element = [RXMLElement elementWith. . . ];
MyDomesticCat* type = [element asCat];
Any XML is ideally a combination on dictionaries and arrays with its root tag initiating a single key dictionary. To take off the overhead of parsing xml to a customized object model you can use the nice framework, XMLReader, available at github.
If you use this framework, your xml parsing becomes as simple as:
NSMutableDictionary* dictionary = [[XMLReader dictionaryForXMLData:<# your xml data #> error:&err] mutableCopy];
NSLog(#"%#",dictionary);
//use dictionary
[dictionary release];
However, you need to pass some well formed xml data as its input. Also you might need to manipulate the content of the parsed dictionary, according to your needs.

Resources