NSDictionary query - ios6

I'm new to iOS 6 and just wanted to post a question regarding the use of NSDictionary or MutuableDictionary.
I'm used to the Android method ShardPreferences where I can write data in key/value format and overwrite etc. etc. Any SharedPreferences file can also be accessed from any scene, like a global class.
Am I looking at the right classes for what I want to do?
Once created can the content be accessed from any scene/class?
Thanks,

you can use NSUserDefaults
With the NSUserDefaults class, you can save settings and properties
related to application or user data.
For example, you could save a profile image set by the user or a default color scheme for the application.
The objects will be saved in what is known as the iOS “defaults
system”. The iOS defaults system is available throughout all of the
code in your app, and any data saved to the defaults system will
persist through application sessions. This means that even if the user
closes your application or reboots their phone, the saved data will
still be available the next time they open the app!
With NSUserDefaults you can save objects from the following class types:
- NSData, NSString, NSNumber, NSDate, NSArray, NSDictionary
If you want to store any other type of object, such as a UIImage, you will typically need to archive it or wrap it in an instance of NSData, NSNumber, or NSString.
Example
NSUserDefaults *sharedPref = [NSUserDefaults standardUserDefaults];
[sharedPref setObject:#"TextToSave" forKey:#"keyToLookupString"];
NSString *myString = [sharedPref stringForKey:#"keyToLookupString"];

I think what you are looking for is NSUserDefaults.
That is the persisted, globally accessible "preferences" for an application.
NSDictionary is just like java.util.Map in Android.

Related

How do I access certain entity associated files from another portal in 2sxc module?

I want to access multiple files from single field of certain entity, which is at different portal. The problem is that when I try to use this example or this one, its field of type Hyperlink contains empty string and method AsAdam(entityObj, "FieldWithFiles").Files as IEnumerable<dynamic> returns empty IEnumerable<dynamic>.
So is there a way to get files data from another portal in module 2sxc?
Environment used:
DNN v.9.6.1
2sxc v.11.5.0
This may fix itself in v11.11, but the general method is as follows:
Get the real file id (instead of the url) by accessing the raw APIs first - kind of like this
var entity = AsEntity(Content);
var realLink = entity.GetBestValue<string>("FieldNameWhichHasTheLink");
// now you have something like file:74 in realLink
// now continue with the DNN API to figure out what file 74 is, and if the permissions allow access

ARKit RealityKit WorldMap Persistence

So I have a RealityKit app, in it I add variousEntities.
I looked for inspiration for persistence at Apple's SceneKit example with the code, which I implemented only to find out missing Entities upon WorldMap Load
I'm assuming you are able to save and load the worldMap from the ARView's session, but the problem is that this only persists the old styler ARAnchors, and not the cool new Entity objects from the new RealityKit features.
The work around that I did, was to initialize my AnchorEntities, using the constructor that takes an ARAnchor. So, from my hitTest, or RayCast, I take the world transform and save it as an ARAnchor, then use that to initialize an AnchorEntity. I gave this ARAnchor a unique name, to be used later to re-map to an entity upon loading a persisted world map, since this map still only has ARAnchors.
let arAnchor = ARAnchor(name: anchorId, transform: rayCast.worldTransform) // ARAnchor with unique name or ID
let anchorEntity = AnchorEntity(anchor: arAnchor)
That's what it looks like before adding the anchors to the scene for the first time. After you save your world map, close, and reload, I then loop over the loaded or persisted ARAnchors, and associate each anchor with their respective Entities, which maps to the name in the ARAnchor.
let anchorEntity = AnchorEntity(anchor: persistedArAnchor) // use the existing ARAnchor that persisted to construct an Entity
var someModelEntity: Entity = myEntityThatMatchesTheAnchorName // remake the entity that maps to the existing named ARAnchor
anchorEntity.addChild(someModelEntity)
arView.scene.addAnchor(anchorEntity)
It's indirect, but taking advantage of that association between AnchorEntity and ARAnchor was the first solution I could find, given the limitation of only knowing how to persists ARAnchors, and not Entities in the worldMap.

Delaying Data Source methods after remote images are downloaded

I'm using this library https://github.com/Yalantis/Koloda
Basically this is a pod that helps me implement a Tinder-like swiping interface.
This pod has a Data Source method called kolodaNumberOfCards(_ koloda: KolodaView) which requires you to declare how many cards the program is expecting to show in the Koloda View.
func kolodaNumberOfCards(_ koloda: KolodaView) -> Int {
return allCards.list.count
}
I am implementing a MVC architecture in my app so I have a Data Model class file which I instantiate at the top of this current view controller.
var allCards = QuestionBank()
In QuestionBank class, I have a list (array) of Card objects which contains all the metadata of the Card objects. Card object also contains the UIImage I want to instantiate in the KolodaCard View.
PROBLEM COMES when I do not have the Card objects in the QuestionBank list array at init! These Card objects are appended to the list after I fetch data remotely from an API.
However, in my ViewController containing the KolodaView, I need to declare how many cards the program is expecting to show in the Koloda View. Since list.count is 0 when you first enter the ViewController, the KolodaView would thus expect 0 card!
Currently my KolodaView is not showing any of my downloaded images.
Is there a way to delay the Data Source methods by Koloda so that the program can wait for all the data to be fetched from API or is there another solution around this problem?

Swift - Spend a lot of data between views: create objects in the first view or connectar several times in the database?

I am PHP programmer and I'm starting with Swift and object-oriented programming and come.
I intend to develop an application based on tables with a SQLite database, something simple, but I'm sure in which to properly desenolver it.
Ahead of the site schedule, I figured it would be basically the same way to program, that is, on the first page I search the database the information that I will use on that page (eg product name) and when the user clicks this product, the link would take you to another page and there again I would connect me with the database and through the ID passed to this new page, I'd get all product information in question (eg. product image, product details, value, etc.)
So, I figured that the same would happen with my application, ie I only spend the ID of a ViewContoller to another, and both View I would connect me with the database and would take the information that I would use for each View.
Seeing some tutorials, I realized that were made differently. On the first view, all information is captured and linked as properties of an object. And in this case rather than sending the ID, the View would send the entire object to another View.
My question is what the correct way to program if I have a lot of information to present. In my case here, I have more than 3,600 products and this product has over 8 properties (long texts) each.
func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
if (segue.identifier == "Foobar") {
if let viewController = segue.destinationViewController as? FoobarViewController {
viewController.somedata = dataInThisController
}
}
}

Access data from a local model

Here is my problem, I hope some one can help me here, I'm developing a mobile app in qx.
In the application.js I call for a JSON in a server through the qx.store.json(url) that creates a model that I bind to a offline model to access the data offline in the app.
Everything good so far then when I try to access the data in the offline model it doesn't let me. The original JSON data is
array(timestamp=>time(),
userdata=>array(
array(userid=>0...),
array(userid=>1...)))
When I debug the JSON or the offline data with obj.getItem(1) it always returns me qx.data.model.userdata.
I'm trying to use the data inside the array of userdata to validate a user in a foreach statement but qx.data.model.userdata always returns undefined.
I try obj.getUserdata(), obj.getItem(1), obj being the offline model.
What am I doing wrong? It isn't a model a store for data, or it can only be used as binding data to an widget?
If the item at index 1 was an Array, obj.getItem(1) would return an instance of qx.data.Array. Since it returns an instance of qx.data.model.userdata, that means the model item is actually an object with a single property named "userdata" and you would access the value by calling obj.getItem(1).getUserdata().

Resources