I'm using the Settings bundle for an iOS application. Is it possible to add some constraints to a field based on another field?
I give an example. I have two fields:
Field1: 10;
Field2: 15;
It is possible to force the user to put into 'Field2' a value that is smaller than 'Field1' ?
Thank you
No, validation logic like that can't be included in the settings bundle. It is a purely static/declarative form of defining the structure of the settings. However, you can of course validate and sanitize the properties at the point where you read them from NSUserDefaults in your app.
Related
I am currently working on an iOS app and localizing it into multiple languages but have faced an annoying (not breaking) issue.
When i would add a new localization for my storyboard xcode will automatically populate the strings, which is very nice. The issue i am having is that i have multiple interfaces which both have a back button. The text on these is of course the same and their translations are as well.
The question i was wondering about, is it possible, without using strings.localizable, to somehow merge multiple object translations into one?
This is how it would currently look:
"Pnu-Ec-HAj.normalTitle" = "Back";
"Rtx-fT-rdc.normalTitle" = "Back";
But it would be way easier if there was a syntax such as
"Pnu-Ec-HAj.normalTitle", "Rtx-fT-rdc.normalTitle" = "Back";
(this syntax is not correct obviously)
I have looked around quite a while but have not found any answers to this question yet.
Thanks for reading.
I'd recommend referencing every text in your storyboard in code, and setting the text on viewDidLoad like, e.g.:
buyButton.titleLabel.text = NSLocalizedString(#"SHOP_BUY_BUTTON_TEXT",#"Button for buying product in detail view");
It's loads of work if you have huge storyboards, but in the end you have a clean Localizable.strings with concise keys and comments, providing necessary context for your translators.
I prefix the key with the section of the app, so for example SHOP_***, USER_SETTINGS_***, etc.
In addition, we use a service like OneSky to organize our translations online and update them from the cloud (not affiliated with them, and it's not without its teething problems either).
Unfortunately the .strings files are key-value files and, by nature, there must be a key (that is composed by the nib ID of the element followed by the property) and the associated string value.
As Apple describes in the precedent link:
The standard strings file format consists of one or more key-value pairs along with optional comments. The key and value in a given pair are strings of text enclosed in double quotation marks and separated by an equal sign.
then, your idea is not supported by the .strings files.
The only way to support that feature is by using the NSLocalizedString in code.
Imagine I have two models for a Greeting Card App: Template and Card. In creating a Card you specify the target's name, age, and which template you want to use (Card belongs_to template). The Template just has say title and body:text attributes.
I would obviously like there to be a placeholder for the target's name (and perhaps age) within the template body, because I want anyone to be able to create a Card, select the template, and see a Card with the chosen template using their target's name. Is there a way to pass in an argument to the body of the Template for the target's name? I have the Card and target info waiting in the controller but I don't know how to pass it the info since in creating the Template the body was typed into a form and is hard coded into the db as an attribute.
The only way around this I see would be to create a view for each Template instead of storing them in the database, or to create several 'chunks' of the template body, and insert the target's name in between. I'd like to figure this out the more efficient way. Thanks in advance!
If you did not want to do this as templates and truly want it store in the db then I would use javascript to replace keys embedded into the text.
This would also offload the search and replace to the client.
I found the easiest way to go about this ended up just using a designated keyword in the attribute and then replacing it in the controller using the ruby method .gsub!
In desktop applications when talking about a config file sometimes it's about letting the end client change some parameters according to his systems - for example entering his system IP or other parameters that can not be hardcoded, and must change by him because the user doesn't want you to know them.
I read about the option to create a settings.plist and reaching the value from NSBundle but how can the end client change the values in it?
You're talking about implementing a settings bundle. Once you've done that, the user will be able to adjust the values in the main iOS Settings app - there will be a section for your app.
There are many Preference control types available. You can use a Text field.
The text field type displays a title (optional) and an editable text field. You can use this type for preferences that require the user to specify a custom string value.
The key for this type is PSTextFieldSpecifier.
To retrieve the edited value at run time, use the below code.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *iPAdress = [defaults objectForKey:#"IP address"];
Once these all done, Go To your iPad default Setting App-> You can view your application name listed under Apps section. Tap on it.
I'm looking to add an embeddedForm dynamically in Symfony 1.4 using Doctrine.
What I'm mainly looking to do is:
1) Only show the relation based on whether or not a checkbox has been ticked
2) If checked, show the embeddedForm
3) Have then the ability to add a new embeddedForm or delete an existing form
I have seen ahDoctrineEasyEmbeddedRelationsPlugin, which looks pretty good with los of configuration. The only problem was that 'newFormsInitialCount'=> 1, means that there is always 1 form as default. I need 0 forms as default and only.
I've also seen a couple of tutorials, but all seem to have at least one relation by default.
For me, the embeddedForm needs to be OPTIONAL, and only display when needed.
Thanks
Follow information based on these links :
http://www.thatsquality.com/articles/stretching-sfform-with-dynamic-elements-ajax-a-love-story
http://www.symfony-project.org/more-with-symfony/1_4/en/06-Advanced-Forms#chapter_06_sub_the_form_saving_process
First is about adding "subforms" with ajax, derived from second you could hide the unneeded form fields and toggle them per javascript (e.g. jQuery.toggle())) !
i need to localize a Reporting Services-report (.rdlc) and i would like to do it using a ressource-file (.resx).
I found pages like this and that and they use custom code to achieve their target.
But pages like Setting the Report Language Parameter in a URL give me the impression that localization in reports is possible without custom code.
So, it is possible to localize a Reporting Services-report without custom code ?
If so, is there a tutorial that explains how it's done?
What in the report do you want to localize?
values from the database? Those should be retrieved from the database in the appropriate language already
fixed labels and textboxes on the report? I have not yet seen any compelling way to doing this - you can either have
one report "skeleton" / template per language (and pick the one you need)
if the number of elements is manageable, define report parameters which you can set from the calling code, to set the labels and texts
use some custom .NET extension for handling localization
It's not really an awfully pretty picture, indeed - I'd be most interested in better solutions myself! (I typically need to support 3-4 languages for any report - and I'm using only server-based .RDL files, no .RDLC, so any localization that depends on client-side resource files is not usable in my case)
I would add one method when it comes to labels and textboxes:
Create a placeholder element within the textbox and use Expression field to
use a Switch clause , switching on the Language parameter.
It's not superpretty, but also works pretty well for 3-4 languages
I am passing parameters to the report for labels etc, and after adding the parameters to the report (using the menu option Report -> Parameters in VS2008) you can then use the values of these parameters to localise the labels. This is workiiing well enough, although it would be nicer to be abkle to refer to resource keys immediately from your form labels etc.