IOS Shortcuts: Setting (nested) dictionaries with application to modify EXIF data - ios

I am trying to set values in a nested dictionary - similar to pythonic dict["key1"]["key2"]=value1 in Apple's my shortcut app on IOS 13. I fail even with a simple dict see attached screenshot which should add an element to the dict. The endgame is to modify EXIF metadata via the Metapho app - non-working example attached
I used ttwo approached
use a basic operation to modify dictionary
use prexisting shortcuts to modify dicitonaries as outline on the following Reddit threat Dictionary utilites.
To reproduce you need to download the attached shortcuts - and Dictionary utilties for the examples using those.
I first checked if I can modify a non-nested dict and nonnested dict.
Modifying non-nested dictionary
Using core tools I cannot add a key-value pair to a dictionary.
Minmal non-working exampleas per below.
Modifying non-nested dictionary using Dictionary tools
Minmal working example
Modifying nested dictionary using Dictionary tools
Using the same tools to modify nested dicts does not work.
Minimal non working example
Any help greatly appreciated. Asked same question on ask different

If values of a dictionary are modified the variable needs to be reset:
reset variable
Using this both nested and non-nested dicts can be modified without external tools.
Essentially this is called by value instead of call by reference. If those tools are used still their output needs to overwrite the variable in question.
Regarding modifying the underlying Exif values it is important it is important that again the output imagevariable needs to be written to new file in the photo app.
Mac

Related

Choosing from a list of dictionaries in iOS shortcuts

In the iOS Shortcuts app, I am using Get Dictionary on my x-callback return, which in fact returns many different dictionaries, which you can cycle through in Quick Look:
How do I allow the user of the shortcut to choose from the dictionaries, for example with the name field being presented to the user for each dictionary?
I imagine a Repeat with Each action is necessary - and indeed I found this answer, which appears to be out of date because I cannot seem to Get Dictionary from the the empty variable - Shortcuts won't let me.

Adding Items from Lists to Dictionaries in Apple Shortcuts

I have this Shortcut which queries a Notion database, then fetches the IDs and titles of pages from the database and turns them into key : value pairs.
I want to add those key : value pairs to the dictionary shown at the top of the screenshot. The problem is, even though I can see that I'm adding to the dictionary inside the Repeat With Each Item loop -
When I check the contents of my Categories dictionary at the end of the Shortcut, those entries haven't been saved.
I have seen this answer, which appears to solve the same problem. But when I implement it and then check the contents of the variable inside the loop, nothing is even being set here.
I'd be very grateful for any pointers here.
I figured out the problem - I needed to set the dictionary as a variable outside the loop -
And then I can update the dictionary inside the loop -
I don't know why that works but it does ¯\(ツ)/¯

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)

What are ways to store complex dynamic objects locally (iOS, swift)?

I have iOS app that takes data from the server as json and then serializes them into objects of different types. Types can be complicated, can contain subtypes, can inherit, so there is no any limitations. Another thing that makes everything even more complicated is some of types are stored as AnyObject? and only in run time they are being serialized into real types accordingly to the specific rules. Something like that:
class A {
var typeName: String?
var b: AnyObject?
}
Then when it's serialized it can be done something like that:
if let someClass = NSClassFromString(typeName) as? SomeGenericType.Type{
b = someClass.init()
}
Also querying should be done on all the data. Currently I'm trying to store all of them locally, then load into memory and query there from the code. I'm using User defaults, but they have some limitations, also I needed to provide custom coding to make it work, and each time when I add a new field it turned out that I missed something in coding and nothing works. So it's pain.
Ideally I would just do some magic command and all the objects are sent to local storage no matter how complicated they are. The same to extract them from this storage. Also, user change data so I can't just store primary Json. And I don't want to covert objects back to Jason as for it's pain too.
Any suggestions?
If you want to use sqlite then You can store whole object in one row! I means you can create table with 2 columns one is id and second is your dataobject(it's data type should be blob). Then convert your whole object into data. Then store in sqlite table and retrieve it as data then convert it to object when want to use. By this way your object will remains in same format as you asked
Firebase while meant for online synching and storage can also cache everything locally in case you are offline and perform query's against the local cache. It uses JSON.
CouchDB also has a mobile version for iOS.
Both of those are over kill if your dataset is small; you can just store it as a text file and read the JSON back in. See performance characteristics here. The graph is for a 7MB file so if you are significantly less than that your load time may be minimal.
NSKeyedArchiver.archivedData(withRootObject:) is great for storing custom objects as Data objects. The only thing you need to do to be able to use this is to make your custom objects conform to NSCoding. A great example can be found here:
Save custom objects into NSUserDefaults
Once you have the Data version of the object, it can easily be stored in UserDefaults, as a property in CoreData, or even in the app's keychain entries. Depending on your use case, sensitivity of data, and how much data you intend to store, you might want to use any number of storage methods. NSKeyedArchiver.archivedData(withRootObject:) allows you to pretty much use any of them.

Method for getting data into game with Objective-C

I'm about to work on a Objective-C game projects, and I'm curious to what's the options for getting constant data into the game. I've worked for many years as a Flash dev and in Flash I would just simply setup a class file and put in it objects like this...
static var arrowData:Object = {
elementType:"projectile",name:"arrow",sourceType:"library", imgSource:"arrow", imageSourceSub:"",cellsX:1, cellsY:1,
bounderyType:"none",bounderyLeft:0,bounderyRight:1200, bounderyTop:80, bounderyBottom:580,
position:{rotateToDir:false,positionType:"movieclip", randomX:false, randomY:false, endRandomX:600, endRandomY:400, startX:0, startY:0},
visual:{imgLabel1:"", imgNumFrames1:15,imgFramesLoop1:true,runOnFrame1:0,runOnFrameFN1:"",runOnLastFN1:""},
movement:{moveType:"arc", maxDistance:400, atTarget:"remove", target:"mouse", targetData1:"mouseX", targetData2:"none"},
physical:{physData:"spritesLayer"},
interactive:{interactionType:"rect", removeOnInteraction:true, interactionResult:"ingame", interactionData1:"badGuysArray", interactionData2:"projectileCollision"},
character:{damage:10}
};
I've Objects inside Objects, but there doesn't seem to be any clear way to do the same with Objective-C, so my questions are...
Is there any way to do the same as the above in Objective-C?
What are the other methods for getting data into Objective-C? XML?
How do iOS game devs usually store their constant game data?
I'm going to be using the parse hosting service with this project, are there
options for using that to store the data and loading it from there?
As the comment by #tc touched on, the common way to maintain groups of related info is in NSDictionaries (or their mutable cousins). Dictionaries can also nest. You have two ways to save these easily: as plists per comment or in the 'defaults' system. The latter is more restrictive on the types of data it stores. Apple also has a class that will convert between JSON and native objects. I have no experience with question 4 - hope others can answer that.

Resources