I am trying to follow "Binding Controls to Input Ports" of Quartz Composer Programming Guide.
The document says :
5.Click “Bind to” and then choose Patch Controller in the “Bind to” popup menu.
6.Enter patch in the Controller Key text field.
7.Enter text.value in the Model Key Path text field.
In my project of Xcode (4.2 &) 4.3, the Controller Key text field is disabled. The Model Key Path text field requires an object of QCPatch class, which I don't think I have a clue.
Should I install Xcode 3.x and handle this & convert to 4.x? Any advice ?
I am experiencing the same issues, however via the kineme forums I have found a work around:
using the Object Controller instead of the Qc Patch Controller:
make a new cocoa project...
add quartz framework via buid phases tab and import the framework to your project either in the pre compile header, or app delegate...
add qc view to your xib and load your composition
add object controller to your xib...
change object controllers class to "QCView" without quotes.
control drag your object controller to your qc view and select "content"
add a slider and bind its value to your object controller and set its model key path to "patch.Text.value" without quotes.....
see this for the full thread on this topic.
in xib file choose the QCView
Attibutes Inspector -> check "Forwards All Events"
hope it helps
Related
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).
I just upgraded Xcode to 8.0 (8A218a) and am converting my project in Swift 2.3 to Swift 3.0. The only issue left now is this error:
"Exception while running ibtool: Cannot find value transformer with
name UTIToIconTransformer"
The UTIToIconTransformer is defined something like:
#objc(UTIToIconTransformer) class UTIToIconTransformer : ValueTransformer {
// ...
}
The code worked fine when it was in Swift 2.3. The binding using this value transformer is set like this:
If I remove this binding, the app runs, and the row titles are shown correctly.
I have tried calling NSValueTransformer.setValueTransformer() in the app delegate's +initialize(), in applicationDidFinishLaunching and in the value transformer's +initialize(), as suggested here, here at StackOverflow and here at NShipster (Though I don't think the statement of "Typically, the singleton instance would be registered in the +initialize method of the value transformer subclass, so it could be used without further setup." complies with the Apple's doc.), all without success.
In the Apple's doc, it says
Value transformers are typically registered by an application’s delegate
class, in response to receiving a initialize: class message. This allows
registration to occur early in the application startup process, providing
access to the value transformers as nib files load.
Availability in Interface Builder
Your NSValueTransformer subclasses are not automatically listed in the
Interface Builder bindings inspector. When inspecting a binding you can enter
the name that the value transformer is registered with, but the functionality
will not be present in Interface Builder’s test mode. When your application
is compiled and run the transformer will be used.
But registering in the AppDelegate's override class func initialize() didn't help. In Xcode 7 and Swift 2.3, it even worked without the registration.
Finally I solved the problem by removing the NSOutlineView from the storyboard and setting up a new one.
I have another project which also has an outlineview binded with an NSTreeController, and that project has no problem after the Xcode 8.0 upgrade. Then I tried creating a new ValueTransformer with a new name, with no luck.
I guess there may be something wrong with the storyboard, so I tried recreating the outline view. Then Xcode doesn't complain that it can't find the transformers!
After some 'cleaning' of a working app, the main window appears as designed in the MainWindow.xib.
I deleted a MainWindowViewController object in IB. (was beneath Font Manager)
MainWindow.xib has it's Custom class set to MainWindowViewController
The table uses Content Mode - View Based
The two required methods ARE included in that implementation file
included in header file
Table view connection has been made to File's Owner
EDIT: Does the full error message give a clue? Why the NSApplication?
*** Illegal NSTableView data source (<NSApplication: 0x100607ad0>).
What am I missing? What should I check to resolve?
Image included to help visualize.
EDIT 2: (New info)
I deleted the data source & delegate connection from the table view and the error disappeared. The same IB designed window opens with an empty table view.
My 'project' is more complicated than the documentation covers. How to add a Window Controller to the Cocoa/Core Data template and utilize this controller is not easily found.
The most pronounced symptom was that the code in the intended controller was not being executed. The 2 required delegate methods were present. awakeFromNib wasn't being called either.
After more research, it appears the 'missing link' is the (previously deleted) NSObject set to the custom class of MainWindowViewController or MainWindowController in the nib file. I'm still looking for why this needs to be or why connecting to the File's Owner doesn't make the connection.
On the one hand, we can set the File's Owner to the custom class (MainWindow)ViewController or (Main)WindowController and connect the contained views to File's Owner. This doesn't work as I expected.
On the other hand, (apparently correct) we can add an NSObject to the MainMenu.xib file, set it's custom class to the (MainWindow)ViewController or (Main)WindowController and then connect outlets to the subviews to this object. The step of adding this object in IB is the only way I could find of connecting the window to the controller.
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.
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.