What does "urSoBasic" means in CAAnimation? - ios

I'm trying to implement some animation via CAAnimation, So I'm finding some references via google.
And I found so many examples are achieve the goal using String "urSoBasic" as a key, like below:
shapeLayer.add(basicAnimation, forKey: "urSoBasic")
The developer documents describing about special key "transition", only about key has to be unique.
Briefly, Is there any function of the key "urSoBasic"? or It's just about convention?
It's confusing.
I want to know what exactly "urSoBasic" means.

The key "urSoBasic" is a joke or a play on words. "urSoBasic" -> "you are so basic". Someone was being cute when they named their basic animation key as "urSoBasic". And then it got copied and pasted a bunch which is why you might find it in various search results.
The value of the forKey: parameter is an arbitrary string that only has meaning to you and your code. It's not even required.
From the documentation for the CALayer add(_:forKey:) method:
A string that identifies the animation. Only one animation per unique key is added to the layer. The special key kCATransition is automatically used for transition animations. You may specify nil for this parameter.
tl;dr - "urSoBasic" has no special meaning that would affect the functionality of the code.

Related

Nested Map or multi-key example Chronicle Map

I have a use case where I want to create a co-occurrence matrix. Essentially it is going to be something like Map<String, Map<String, Long>>. I wish to use Chronicle-Map for this task.
I checked Multimaps in ChronicleMap and https://github.com/OpenHFT/Chronicle-Map/issues/100. However, I am unable to follow the discussion to make a suitable change.
It would be also okay to have it like a multi-key like Map<String, String, Long> . I looked up the graph example of add and remove edge (in chronicle-map tutorial) which was again too detailed and complicated for me to adapt to my setting.
The way this will be used is to query:
Getting the long value for a very specific combination if key1 and key2.
For a specific key1 return all the key2 along with their respective long value.
Can someone please advise and provide a simple working example.
You need to create a MapMarshaller based on the source of SetMarshaller (yes, it's going to be even more complicated). Or use a Pair<String, String> as a key.

Have UIActivityItemProvider return multiple objects or nothing?

I have a Book class and I want to allow my users to share their progress for each book. To do that I present a UIActivityViewController, but I wanted to add different texts for Facebook, Twitter etc., so I had Book conform to the UIActivityItemSource protocol, and then I can return a different value for its methods depending on the activityType. So far so good.
Now I want to also share an image when the user selects Facebook or Twitter, but just text for all other options. The methods in UIActivityItemSource only let me return one object, though. To share both a string and an image it seems I'd have to add them as different activity items, but then I don't know which activityType the user will pick to decide if I should include the image or not.
So how can I share a different number of objects of various classes and values depending on activityType?
Thanks in advance,
Daniel
Edit: Now I'm trying to do this with UIActivityItemProvider… the thing is, sometimes I want to share just some text and sometimes I want to share an image too. So my UIActivityItemProvider would have to return multiple objects conditionally (sometimes it would return an image and sometimes it would not) or I would need to use more than one provider and have the image's provider return nil sometimes, but that doesn't seem to be possible. Now what?
I found a way to work around my problem. It's not great, though, so I won't accept this answer, but I'll leave it here in case it helps someone.
I can't have a UIActivityItemProvider return nil but I can have it return an empty string, so that's what I did – for the activityTypes I want an image I return an image, for the ones I don't I return an empty string. Then I have another provider for the text.
There are a few drawbacks, though. Returning an empty string creates a new line, which isn't a deal breaker, but it's annoying. Also there will always be a string item, even if I return an empty string for my text provider, so options like saving to the camera roll won't ever be available.
I'll do this for now, but if anybody has a better suggestion please let me know.

How do we know what gets done with data objects passed to UIActivityViewController?

For example, the documentation for UIActivityTypeAirDrop states
When using this service, you can provide NSString, NSAttributedString,
UIImage, ALAsset, and NSURL objects as data for the activity items.
You may also specify NSURL objects whose contents use the
assets-library scheme. You may also provide NSArray or NSDictionary
objects that contain the listed data types.
But how do we know what exactly is going to be done with each of the data objects? Do we just need to experiment to find out? Same for the other UIActivity types, none of them say what is specifically done with the objects.
Unfortunately the documentation for this controller is not that comprehensive and there are not too many details on this. Experimentation is pretty much what I've ended up doing. Some of them are common sense though, such as "Save to Camera Roll" requiring an image object. Most of the others will try to use whatever you give them (URL, text, image, etc).
I would implement your own UIActivityItemSource to pass into the controller, and return exactly the media you want for each individual activity item type so that there is no ambiguity in what will actually get passed to the user.

SWFAddress used to change INDIVIDUAL params in the url

I am using SWFAddress in actionscript 3 to control urls for navigation and controls, and while I am able to target and change specific parameters, I feel like I am missing a cleaner and more consistent way of handling it, perhaps even a feature or method I am not aware of.
Say I have a url and I want to change just the second param of def to xyz.
http://localhost/some-page/#/?param1=abc&param2=def&param3=ghi changed to
http://localhost/some-page/#/?param1=abc&param2=xyz&param3=ghi
I currently am doing:
if (SWFAddress.getParameterNames().indexOf("param2") >= 0) {
SWFAddress.setValue(SWFAddress.getPath() + "?"
+ SWFAddress.getQueryString().replace("param2=" + SWFAddress.getParameter("param2"), "param2=xyz"))
Essentially, checking if the param exists, checking what its current value is, then recreating the whole url using base, '?", and query, making sure I replace the the parameter and the parameter's value, making sure I don't miss the equal sign. This get's sloppy, and is error prone if the param exists but is not set to anything, or whether or not there is an equal sign, and a host of other pitfalls.
So, I can not just tell SWFAddress to update that one parameter in the url? A theoretical function of SWFAddress.setParam("param2, "xyz").
Has anyone coded their own method to micro-manipulate SWFAddress and the url, beyond the single function they supply you with of setValue(val:String)?
I think the short answer is no. According to the documentation there is no setParameter to go with the getParameter method. Looking at the code, it seems that the URL is not cached as a property in the class and therefore cannot be manipulated other than via the setValue method which, of course, updates the URL in the browser.
Presumably you're already parsing the URL in your onChange event so you can use the values to set your application state? If so, you shouldn't need to do so again when you come to rebuild the URL prior to updating it from Flash. If you store the deep-link properties on a Model class somewhere you can handle the defaulting, updating, and error checking without needing to resort to String manipulation. You would then rebuild the URL using those properties, a process you could abstract into a method in your Model class if required.
You should also note that the following line is not particularly robust since it will return true for properties such as param22 and sparam2:
if (SWFAddress.getParameterNames().indexOf("param2") >= 0) { }

GWT JSONObject adding an additional incorrect key when converting overlay type to json string

I'm encountering the following problem - I have simple GWT overlay types, and I'm trying to convert one to a JSON string on the client; I'm simply doing:
new JSONObject(this).toString();
The conversion works, but it adds an additional, incorrect key to the json string, such as:
{"key1":"value1", "key2":value2, "$H":1}
where "$H":1 doesn't correspond to anything in my overlay type.
Any idea why this is?
Any help is appreciated on this, thanks.
This issue is define in this link
The $H property comes from the
implementation of
JavaScriptObject#hashCode() (in
com.google.gwt.cire.client.impl.Impl#getHashCode(Object)).
In your case, this is due to
AbstractEditableCell maintaining a map
of value keys to their "view data",
and your use (I guess) of the default
ProvidesKey implementation
(SimpleProvidesKey) which directly
returns the item.
So, when rendering, the EditTextCell
calls getViewData, which looks up the
key in the map (and thus needs the
hashcode of the key, hence the call to
hashCode), and the key is your JSO
(hence the new $H property).
I believe that giving a ProvidesKey
implementation (in you case, returning
the name property for instance) to the
Celltable would solve your issue.

Resources