phalcon selectStatic default value - phalcon

are there other ways to set a default value for selectStatic tag in PhalconPHP other than setting it in the controller using
$this->tag->setDefault();

You can add this to your services
You can add this to base controller's initialize() function and all your controllers must extend this base controller.

Related

Can I get strongly typed controller from `ActionExecutingContext`

From this SO question I see that it is possible to get the controller and action from ActionExecutingContext, but as strings.
Is there a chance to compare that in typed way like comparing to the controller class (e.g. HomeController) or the actual controller is not instanced at that point?
That question I referenced is for old asp net.
Fortunately, in aspnet core ActionExecutingContext, has a property Controller with the actual instance of the controller, and not a string.

Get WatchKit interface controller instances created with presentControllerWithNames:contexts:

I'm presenting a page based modal using [self presentControllerWithNames:self.controllerNames contexts:self.controllerContexts];, where controllerNames is just an NSArray of NSStrings containing my interface controllers names. The problem is that I would like to access the created controllers.
The documentations says that
WatchKit loads and initializes the new interface controllers and animates them into position on top of the current interface controller.
but I would like to have a reference to them, in order to call the becomeCurrentPage method from outside.
So, I would like to be able to save those controllers after they are created in a list, and programmatically change the page using something like [self.controllers[2] becomeCurrentPage].
Because you're allowed to provide a context when you present an interface controller, you can pass a reference to self. That way, you can establish a reference from the presented controller to its parent. Once that relationship exists, you can use things like delegation patterns to communicate.
I use this extensively in my own Watch app, and I've wrapped a lot of these mechanics in my JBInterfaceController subclass on GitHub.

Does Razor View #model initialize the model?

I have a razor view which uses the #model keyword. I added a breakpoint in the model's constructor and whenever the view is rendered the breakpoint does not get called meaning it does not go into the constructor.
No. #model only declares the model type. If you need an instance of the model, then you must create one in your controller and pass it to the view, ie :
return View(new MyModel());
However, it's not always necessary to create an instance. This is only necessary if you need to access instance properties, such as a list of items that you need to iterate over.

What is the purpose of the User Defaults Controller?

In Xcode, I'm making a Mac application in Objective-C. In designing my application's window, I realized there was an object called the User Defaults Controller in the Object Browser. What is this for? I know what the user defaults are, but what is the purpose of this in the object browser? What would be an example of when one would use this? Thanks!
The Controller's purpose is to bind your User Interface elements to the User Defaults.
As an example, you can have an NSTextField in your interface representing a configuration preference (for example default document title). You bind this to the User Defaults Controller. With this method the user can specify a default title that is being saved or updated automatically by the Cocoa Framework without writing a single line of code.
To to this, in IB put a controller and a textfield. In the bindings inspector, set the textfiled's String property to bind to the User Defaults Controller, set the Controller Key to values and set the Model Key Path to the key used in User Defaults.
It's used by Cocoa Bindings, to allow binding of UI elements to the NSUserDefaults.

How to force interface builder (storyboard) to generate controller initialisation code?

I am getting incredibly frustrated with interface builder at the moment, and would appreciate some help before I ragequit it and code everything by hand (which seems to be much, much, much easier).
The basic situation is this: I need to make a model variable accessible to each view controller in my application.
The simplest way I can see to do this is to just create a property on the view controllers that retains the model, and to set that after the controller is initialised.
However, I can't find any of the actual initialisation code for the views shown on the storyboard in my project. There's no reference to any of them at all. Does the interface builder really generate not generate any code reference to its controllers in the app delegate?
For that matter, why is there no reference to any of the top level controller objects (tabview, tableview etc) in code at all?
All I want to know is how to force xcode to actually generate the controller creation code in AppDelegate.m - so that I have access to the created instance of the controller - or, failing that, a way to share the model between these amorphous objects.
Maybe it would be easier to create a singleton class where you can store all your global variables and methods. Example here.
You will need to manually create a subclass of your view controller and then override the methods you want to inject code into. In Interface Builder you can then choose to make your View controllers of this custom type.