Swift 2.0 Core Spotlight API - search only for title - swift

I'am testing the new Core Sportlight API feature in iOS 9. The indexing process works well but is there a way to define that the indexed Item should only get searched by the "title" Attribute instead of "title" and "description"?
Maybe you already have some more informations than me.

I have tried doing this using Objective C, and it works perfectly.
It depends on what implementation of "CSSearchableAttributeSet" is used.
In obj C, there are many implementations of CSSearchableAttributeSet like
CSSearchableItemAttributeSet_General
CSSearchableItemAttributeSet_Document
CSSearchableItemAttributeSet_Image
and others.
I have used CSSearchableItemAttributeSet_General in my code and I'm able to search by the title attribute only. In fact, that particular implementation of CSSearchableItemAttributeSet doesn't even have a "description" attribute.
So depending on what type of object you want to search for, you can use the particular implementation.
I believe it would be the same equivalent class in swift as well.
-Tejas

Related

How to call google map api using swift 4?

My issue is a, I need only restaurant, bar using google API.
If you need code i'm send you.
this is my base url:- "https://maps.googleapis.com/maps/api/place/"
nearbyURLFragment :- let nearbyURLFragment = "nearbysearch/json?key=%#&location=%f,%f&rankby=distance&type=restaurant,bar"
a single type of proper working.
but here is I'm not getting a proper result.
Quoting the Google API Docs,
Restricts the results to places matching the specified type. Only one
type may be specified (if more than one type is provided, all types
following the first entry are ignored).
The only workaround of this would be to define one in the keyword attribute however this will return very inconsistent results.
The best way to do this is to do two separate API calls with differing types.

Mirror formatting spring-data-rest/spring-hateoas in custom controllers

I used the suggested approach in this question to return HATEOAS formatted outputs that match those returned by spring-data-rest. It works good, but is there a way to avoid boiler plate code to create entity resource assemblers like the QuestionResourceAssembler in the referenced question, if I only want to add 'self' links using the id to all entities? Perhaps using ResourceAssemblerSupport?
The easiest way is to simply use the Resource wrapper type:
Resource<Person> personResource = new Resource<>(person);
personResource.addLink(…);
personResource.addLink(…);
Links can be created either by simply instantiating them (i.e. new Link("http://localhost/foo", "relation") or by using the ControllerLinkBuilder which allows you to point to Controller methods for obtain a reverse mapping. See this section of the Readme for details.

Why indexers don't work in WP8 bindings?

I am trying to bind an element from the view to a matrix in the view model. In the binding I want to use indexers so I can retrieve the element that I want. The following syntax does not work:
Fill="{Binding OwnBoard[0\,0], Converter={StaticResource BoardToBackConv}}"
If I remove the indexers, the binding is done and I get the value of the OwnBoard Property in the converter, but once I add the indexer, this does not work anymore and the converter is never called.
Do you know why this does not work in Windows Phone 8?
Unfortunately, it looks like two-dimensional indexers aren't supported in Silverlight (Windows Phone .net apps are based on Silverlight): http://msdn.microsoft.com/en-us/library/cc645024(v=vs.95).aspx/html#indexdata
Only one-dimensional array indexing is supported.
As a workaround I would suggest to use a converter, but since you're already using one you'd have to find a way to chain two converters.

i18n in Symfony Forms

Is there any way I can use the format_number_choice function inside of a actions file. In fact I need to use it for a Form error message.
'max_size' => 'File is too large (maximum is %max_size% bytes).',
In English it's simply "bytes", but in other languages the syntax changes after a certain value (for example if the number is greater than 20 it's: "20 of bytes").
I can use parenthesis, of course, but if the framework offers support for doing this specific thing, why not to use it?!
The way it's currently implemented in the 1.4 branch, you can define only one translation per message using il18n XML files.
What you could do is create a custom validator which inherits the current validator (sfValidatorFile in your example) and does the size checking in the doClean method before calling its parent's method.
I suggest you take a look at the source to see how it works : sfValidatorFile
The correct way to handle number ranges for translation is explained here in the Definitive Guide. I won't reproduce it here as the documentation itself is clear and concise. Note however that the string is not extracted automatically by the i18n-extract task, so you need to add it manually - again, the documentation explains this.
So yes, you can use the format_number_choice() function inside an action - you just need to load the helper inside the action like this:
sfContext::getInstance()->getConfiguration()->loadHelpers('I18N');

Drupal - dynamic options for text_list field

I have a custom node type for which I want to have a field that uses a special combobox based on list_text. When one chooses the type list_text it is normally possible to enter a static list of selectable texts, however, I want this list to be dynamic, i.e. based on the results of a db_query. What is the best way to do this using Drupal 7?
A simple example for clarification: A node of this custom type X contains a field that points to another node, so whenever a node of type X is created I want a combobox that contains all other nodes.
(Best solution would be to only display the combobox during node creation, and no longer during edit. But I could also live with it if the combobox was shown during the edit as well.)
I have tried to customize options_select by defining my own data type and implementing hook_options_list accordingly. The combobox was displayed during creation with the correct values, however, I could not save it.. I have no idea what went wrong there, but on the first submit it would change to a different theme, and when I tried again I got an internal server error. Am I on the right track at all with defining a completely new data type for the field? there surely must be a simpler way?
You're right in that you don't need a new datatype. Here's a good tutorial on how to do this. It's not specifically for D7 but I didn't see much that wasn't still applicable. There may be a better way to do it in D7 specifically but I would love to know it too if so :)
The tutorial linked by allegroconmolto sent me on the right way. Thanks for that.
Here's the simpler way of doing it: tutorial
Basically, it is, as I assumed, a common problem and hence a simple solution for it was included in the webform module by now. It provides a hook_webform_select_options_info which can be used to register a callback method. The callback method is then called each time a corresponding option select of a webform is shown, so that you can easily fill it with the results of a dbquery or anything else. Works like a charm and takes next to no time to implement.