What does exposeBinding do? - cocoa

I have been using bindings without having ever heard of exposeBinding.
Is it only intended to plug-ins ?
What does exposeBinding do ?

Expose bindings are nothing special, it is just normal binding what you see in the Xcode. But why its named is expose binding becuase when you do any binding in the interface builder. It causes second binding automatically in the interface builder which is called expose binding.
For your understanding i have attached the screen shot in which inside binding inspector i have just bind file owner to the hidden in Availablity section and then you can see below automatically it created hidden2 inside Availablity section below. This new binding hidden2 is called exposed binding. And also the used of these binding values are then used together in returning the final value of the binding. Please follow the attached screen shot:-

From the doc.
exposeBinding:
Exposes the specified binding, advertising its availability.

Related

No need for ViewModelLocator if using RegisterForNavigation?

In prism we can have ViewModelLocator resolve the VM when we navigate to a View by setting the attached property prism:ViewModelLocator.AutowireViewModel="True"
However, in the PRISM samples on Github, the container is initialized using the extension method (RegisterForNavigation) which seems to do the same thing.... ,
containerRegistry.RegisterForNavigation<MainPage, MainPageViewModel>();
I am wondering if the RegisterForNavigation has made the AutowireViewModel attached property approach obsolete?
I am wondering if the RegisterForNavigation has made the AutowireViewModel attached property approach obsolete?
No, this kind of registration just - additionally - defines the view model to be used for the registered view directly (instead of relying on the convention configured in the view model locator).
Setting ViewModelLocator.AutowireViewModel is still required to actually create the view model (whether it's type is defined manually or derived from the view's type by a convention).

Which methods in PropertyProvider are used during code generation?

I have implemented a UITestPropertyProvider for my custom control following the steps here: http://msdn.microsoft.com/en-us/library/hh552522.aspx
When I use the Coded UI Test Builder I can see my custom properties on my custom controls and I can record steps that interact with the control and the code generates and playback works fine. But when I try to add an assert on any property--not just the custom properties added through PropertyProvider--when try to generate code for that I get an error that says "Cannot add the same member twice to a SerializationInfo object."
When I remove my custom property provider I can still record and playback clicks and stuff and I can assert on any property, but I cannot access my custom properties.
There's got to be something wrong with my PropertyProvider but I don't know what. Which methods of the PropertyProvider are being used during code generation?

How to create NSFetchedresultController on cocoa using NSArraycontroller?

i have to port existing iOS code (which is using NSFetchedResultController) to OS X, can u please give me some code snippets on how to get contentWillChange and contentDidChange events using NSArrayController.
You don't. NSArrayController does all that, and more, when you bind it to a tableview and set its entity type properly.
Using bindings you can remove all of the table data source code that you had for iOS.
If you want to recreate NSFetchedResultsController, you need to listen to managed object notifications and act on them in the same way, but bindings is much easier.

NSArrayController and referring to a shared, static, Core Data based library

Using this guide I have created a static library (let's call it AppCore) that can be shared between the Mac OS X and iOS versions of one app. This static library uses Core Data and the point of it is to share the model part and schema versioning between different implementations.
I created a NSPersistentDocument based project that will depend on this AppCore. In this project I added a reference to the .xcdatamodel file. Then I created a simple table view with add/remove buttons to edit an array of one entity type with the assisted "new core data entity" item. This created an instance of NSArrayController and the required bindings for the add/remove behaviour.
Now, everything seems to work fine when I'm using the default class for the Core Data entities (NSManagedObject) and I'm able to add new rows using the +/- buttons. However, when I change the entity implementation class to a custom one, I'm getting an error
Failed to create new object
This seems to come from the NSArrayController and it seems to be unable to instantiate the required entity. I can, however, create one in the NSPersistentDocument subclass by:
[NSEntityDescription insertNewObjectForEntityForName:#"SomeEntity" inManagedObjectContext:[self managedObjectContext]]
What confuses me is why the instance of NSArrayController can't. If I understand correctly, the array controller is instructed to create an entity, not class and my guess is that the entities are created with the help of NSEntityDescription class. I could implement my own version of the array controller's add: but then again, it might be that here something is fundamentally wrong. I haven't touched the init:s and the custom entity class implementation is simply for convenience, to access the attributes directly.
I have tried changing the base SDK on the AppCore but without effect. Currently it uses the iOS version but I'm not sure how it should be. This is another question but if unrelated, I might ask it here on a separate question.
So, to summarize, why can't the NSArrayController create an instance of this entity?
Thanks in advance.
Update
This works if I add the SomeEntity class from the AppCore to the dependent project as a reference. This is not the most usable way since modifications to the AppCore has to be propagated to the dependatnt projects also.
Bingo. I missed the "-ObjC" flag for the dependant project's "other linker flags". Now everything works like a charm.

Cocoa Touch App Architecture - MVC controller?

I am quite new to Cocoa and to iPhone programming.
I am using the Xcode Utility Application template to implement a simple app that has:
a view with a text field to collect a username
a view with a connect button to start a connection to a remote site using the
username to get some data via HTTP. The data will be presented as a text string on the screen.
I think this represents my VIEW in the MVC pattern.
I created a simple class to store the username and to do all connection work that represents my MODEL and instantiated it inside the AppDelegate.
Here a really simplified sketch:
It is not really clear to me how can I get data nested deep into subviews (username) or how can I trigger actions in nested parent views (connect button).
My question is:
What is the best/cleanest way to implement this architecture?
How do I implement the CONTROLLER?
Thanks in advance for any help,
Paull
Updating my answer based on comment:
It's in most cases ok to have state in your controller. Like an array or an instance of whatever modelobject you are writing an application for.
I would keep the model object clean of any networking code and put that in the Controller instead though. In this case the ViewController where that connection action is triggered.
Original answer:
It is not really clear to me how can I
get data nested deep into
subviews(username) or how can I
trigger actions in nested parent
views(connect button).
With the utility application template you already have a couple of ViewControllers.
To get references to your UI inside your controllers you need to declare IBOutlets and connect them inside Interface Builder. To respond to actions you need to declare and implement IBActions in your ViewControllers and hook them up in Interface Builder as well. Which you do in Connections pane (2nd from left) in the inspector.

Resources