Core Data: Passing a managed object to a class - core-data

I have an app that stores product data in Core Data. I have a popover controller where you select a client, it calls back to the root view controller through Notification Center and then root vc gets that clients purchase agreement from core data. We store it as a property of the vc (workingPA).
That purchase agreement data is then displayed. We have a calculator class (subclass of NSObject) and when the user makes edits to the PA it fires up and runs a bunch of calculations, getting base figures from the PA managed object we retrieved from Core Data. We're passing the PA to the calculator class from the root vc like so:
calculator.workingPA = self.workingPA
My question is this an acceptable way to pass a Core Data object to another class or is there another, "best practice" to accomplish this?

Related

Blue Prism Applicatoion Modeller Wizard sharing

I have a new object in BP where I would like to include the application model from another object, but how do I share it from the "old" object?
In the Application Modeller Wizard there is a choice to Share the app. model from another object (see pic.) but I can not find the place in the parent object to enable sharing.
And yes, I know, I could just add a new page in the parent object, but I would like to keep it separated if possible.
If you'd like to use the application model between objects, then you need to share it first.
Go to object, that has application model that you want to share
Double click on "Information box" on initialise page
On the sheet Information sheet you can see a checkbox called shareable
Tick it and save the object
You should now be able to access that model from different object

How do you return a data object from a subactivity in a UML activity diagram?

I'm trying to create a subactivity that outputs a data object.
Currently, I have a subactivity, Prepare Pack, that adds a Joker card to the Card Pack data object, removes all twos, threes and fours from Card Pack and returns Card Pack.
To model an output I connected the subactivity to Card Pack data object with an arrow. Is this a valid way of illustrating that the subactivity returns Card Pack?
So here is how I would model it. Given you have the sub-activity modeled with containing actions like this
the card deck is fed in via an object node and leaving via a second one. Another view shows that without the inner structure:
(Note that the lying 8 is a decoration from Enterprise Architect to show the the element is clickable and contains a diagram showing its inner structure.)
Now this activity can be used as invocation like this:

iOS 8 - Adding user input before CoreData updates object and tableView

I'm barely new to iOS (Swift or otherwise) programming.
I've started coding an App using Master-Detail Application (with CoreData) template.
The problem I have is I cannot find the way to make the user input data and then take these values into the newManagedObject.
No matter how I do it (i.e., alerts or even another view) CoreData creates the object first (giving an error cause variable value is empty) and then presents the user with the option to input data (although whatever method I user to present data is always before the newManagedObject.setvalue execution line.
Thanks!

Autofilling Part Values in an Orchard Controller

I'm very new to Orchard (and ASP.NET MVC) and I'm having some difficulty wrapping my head around how Orchard part properties can be automatically set in a controller. I have a "Gallery" content type, consisting of the stock Title, Container and Owner parts. I'm creating a controller with a Create method that hides all of the details of the Container part since I'm going to set the default page length, the item type, et cetera in the HttpPost version of the Create method. My problem is I don't know how to set those values on the http Post.
My general plan was as follows:
I created a CreateGalleryViewModel containing the title and admin username, both as a string. IN the view those two are represented as form fields. On the submit, I could run TryUpdateModel in the controller to update the CreateGalleryViewModel with the form values. But then how do I update the Part properties? I think I'm supposed to run IContentManager.UpdateEditor(, this) but I don't think this ca, work because I never ran IContentManager.BuildEditor in the first place. Here's where I'm stuck because I don't see how the content parts get validated and updated properly.
Am I looking at this at the wrong level of abstraction? How do I make a simplified editor for my Gallery content type?
What you basically need to know here is the following:
You can build the editor of a content item with IContentManager.BuildEditor()
You can updated an item's parts' values from the POST data with IContentManager.UpdateEditor()
You can also access parts by "casting" content items with the As() method (needs the Orchard.ContentManagement namespace).
When you're dealing with content items because of their dynamic nature it's rarely a good approach to create a view model where you recreate some of the parts' properties. If you have such static view models for what's contained in a content item then you'll miss the extensibility and flexibility that comes with Orchard's content model. E.g. if you add a new part to that content type since you're using a static view model the new part won't be handled.
For a complete example of how to manage content items from code, see the Training Demo module.

How to add a property an ASP.Net user control or web page and have that property read by Microsoft coded-ui testing? (CUIT)

I am using Microsoft coded-ui testing (CUIT) in VS 2010 Ultimate to test an ASP.Net 4.0 site.
I have the source code to the ASP.Net site, so I can modify it as needed.
I've got record/playback working.
I can write simple assert statements in the test methods to check properties of the UITestControl descendents (HTML links, tables, etc.) and compare them to expected values.
I want to add properties to user controls (ASCX's) and pages in my site, to pass back useful values to the testing code.
For example, I have a user control that implements a menu which displays different sets of menu items depending on the role of the current user.
Rather than having the test script click at the various menu items to check whether or not they're present, I want to add a property to the user control. This property will return info to the caller, listing the menus and menu items present.
I've found info on the Net on how to do this in WinForms, but this code relies on accessability, which I believe is only useful for CUIT with WinForms. Likewise, I've found info on how to do it with WPF/SL.
The answer may be related to getting the UITestControl.NativeElement property, then calling a method that overrides GetProperty(), but I haven't been able to get this approach to work.
Can anyone provide a short code sample showing how to add a property to an ASCX or ASPX page, where that property can be written in C# code-behind, and read by Microsoft Coded UI Testing (CUIT) code?
Thanks!
Adam Leffert
http://www.leffert.com
I haven't found an answer to this question, but I have written some code to solve the underlying problem.
I realized that adding properties to user controls would keep the validation data together with the control under test, but only for the case where the section of UI was implemented as a user control.
There are at least two other cases I need to cover:
1) Third-party controls added to the page, for example ASPxGridView, ASPxTreeView, etc.
2) Items that are not visible in the UI, for example the user profile data for the current user.
When you're running CUIT validation code with a Web app, the data you have available is DOM data, i.e. a tree that represents the contents of the Document Object Model of the contents of the browser window. There is no Request object, .Net Page object, etc. This DOM data is accessible through the UIMap object.
I don't want to wrap the third-party controls in user controls, because doing so would disturb the application under test, causing me to re-write the application code that touches properties and events of the grid, tree view, etc. Too intrusive for testing code.
So I created a code interface (ITestable) that contains a dictionary of string values, and a list of ITestable children.
In the LoadComplete event handler of the master page, I create an ITestable for the master page and fill the list with child ITestable objects for the child page, which can themselves contain lists of children.
I serialize this object into JSON, then store it in a hidden field on the master page.
I added the hidden field to the UIMap.
The test validation code deserializes the ITestable, then looks through it for values that need validation.
The controls create their own ITestable objects, so they can easily fill the objects with values that may be needed for validation, rather than forcing the test code to manipulate the UI trying to read validation values.
For example, a tree view could return its contents without the testing code having to click on each node and try to read the value displayed there. Additional properties (visible, enabled, etc.) can be stored in the values dictionary for each ITestable object.
CUIT has some very powerful features. I would very much appreciate it if Microsoft would document some best practices for solving these non-trivial validation problems. I've read through the Microsoft documentation but haven't found much on this topic for Web apps.

Resources