Core Data error - Swift - core-data

I'd like to use this line of code, but xcode says: Type 'ViewController' does not conform protocol 'NSFetchedResultsControllerDelegate'
Code:
fetchedResultController.delegate = self
Does someone have a solution for this?

your class of Type 'ViewController' needs to conform to the protocol 'NSFetchedResultsControllerDelegate'
a protocol is an interface and you need to implement the methods it defines
(and maybe [and I mean this in the least offensive way] read a book / a tutorial / attend a course to learn OOP and swift and cocoa touch)

Related

How to navigate through association class to create constraints with OCL?

I'm struggling to find a way to navigate through association class to create constraints
I checked on the specification here: https://www.omg.org/spec/OCL/About-OCL/
It's says:
Let say I have this class diagram:
And this object diagram:
As you can see I created a constraint in the context of class A (just below the name of the class), I tried with lower "c" and upper "C", neither work...
Context A:
inv: self.C[b].val.mod(2) = 0
(The meaning of the constraint is not important, i just would like to make it work)
When I execute the validation process I get this error:
"Expression has errors: Semantic errors at [0:5]: Unrecognized variable: (C)"
This error message seems to be logic as I don't see an attribute "c" or "C" either in the object of type A, but I don't understand why it's that so.
Am I doing something wrong ?
I don't understand why it doesn't work as I respected the syntax described in the specification.
For information:
I use:
magic draw: v18.5
OCL: 2.0
Thank you by advance !
You looking at a very dark corner. My first attempts at actually testing this functionality foundered on a failure to find a UML tool that could actually draw Fig 7.1. Once I got to grips with the text I realized there are many problems; a potential conflict between two different x[y] syntaxes, further aggravated by a QVTo shortform. There is a problem with extension to more than binary associations. The OCL Abstract Syntax continues to use the UML 1.x concepts of AssociationEnd rather than the UML 2.x Property.
Consequently the functionality you observe is the result of the best endeavours of some tool vendor to make sense of a very inadequate specification.
With MagicDraw, you used to be using Dresden OCL, but I understand that MagicDraw has switched to Eclipse OCL, perhaps the Classic Eclipse OCL. NoMagic seem remarkably reticent in crediting the open source software they redistribute.
For the newer Pivot Eclipse OCL where I prototype solutions to many of the OMG OCL problems, the UML to Pivot loading normalises many of the UML concepts so that Associations are redundant, unless an exoplicit navigation to the Association requires an Association Class to be reified. AssociationClasses are normalized to Association Classes with ordinary Properties for each plausible navigation.
I think that your expression is incorrect.
self.C[b] cannot be a qualified association since the implicit A::C property has no key.
self.C[b] could be a disambiguated navigation A::C where the ambiguity of A::C is resolved by selecting the C::b opposite. But A::C is not ambiguous and its opposite is C::a. So self.C should be adequate, self.C[a] is redundant, self.C[b] is wrong wrt the b. Sadly your tooling dislikes self.C so your tooling is defective.
I think you should have written self.C.val.mod(2) = 0.
Uppercase C is correct. Lowercase was misguidedly suggested by OCL <= 2.2 following the UML style guide. See indented paragraph under "Missing Association End names" in 7.5.4 of OCL 2.4.

What name does this syntax have

In the language nim, one can do the following thing:
let num = 5.add(3)
which would be the same as
let num = add(5,3)
So, basically you take the expression before the dot as the first argument to the function.
I'm sure other languages have this feature, but none directly came to mind.
What I want to know is what name this syntax has
In D lang this syntax is called Uniform Function Call Syntax (UFCS).
The manual says it's the method call syntax. It also mentions dot operators.
TL;DR - Unified [Function] Call Syntax, or whatever you like, because there's no stable widely accepted term for that in software engineering.
The concern is based on the info about programming languages that somehow implement this feature:
C++: The most generic name for the feature is possibly Unified Call Syntax as defined by Herb Sutter at open-std.org paper in cooperation with Bjarne Stroustrup as a possible new feature for further C++ standards.
D2: In D language, and also in and RFC for the Rust Language it is called UFCS (Unified Function Call Syntax).
MATLAB: In MATLAB they don't use any specific naming for the fact methods can be called either via function notation or via '.' (dot) syntax.

OCUP UML operation semantics example

I am currently learning for the OCUP UML Fundamental exam.
While reading the book i found something strange about operations.
The semantics of an operation:
[visibility] name (parameter list)[:type][{property strings}]
now there are the following examples:
- getPoistion(return x: int, return y: int)
- enlarge(byFactor: Real) : GeomFigure
- +addPhone(phone:String)
- deposit(in amount, Amount): Amount
- #release(): contractStatus
- "create"create()
The last one i think is odd. Can someone explain me why this is allowed?
Since the only semantics that is allowed before the name is a visibility modifier.
Kind regards,
Wim
The chapter 2.2.11 OPERATIONS, page 49, in the book http://issuu.com/maurosergio/docs/uml_2_certification_guide_-_fundamental_and_interm that you are quoting also says
..Notation and Semantics..The syntax for operations..the notation should look like this..
The notation does not define/restrict semantic meaning of operations. It specifies general useful syntax.
The "create" message has in UML special behavioral meaning (don't know where is it explained in the book you are reading). For example look here http://www.uml-diagrams.org/sequence-diagrams.html, see <<create>> stereotype in the diagram and create message later in the text.
Also see "Object Creation Message" chapter here http://www.uml-diagrams.org/uml-object-oriented-concepts.html#message
Kirill Fakhroutdinov's online book www.uml-diagrams.org is very good UML reference compiled by the author from official sources (UML specs) and also from other background non-UML sources and from some "common sense".
Browsing through this book might be easier way to prepare for the exam, or at least consider it as alternative reading. Many "visual" examples included
and welcome to Stack Overflow and also read https://stackoverflow.com/help/someone-answers
Where exactly have you found this example? It really looks like incorrect and definitely does not comply to the formal expression stated above.
These are the examples frm the last version of UML spec and all are perfectly fine:
9.6.5 Examples Normal Operations:
display ()
-hide ()
+createWindow (location: Coordinates, container: Container [0..1]): Window
+toString (): String
A template Operation: f <T:Class>(x : T)
A binding of that template Operation. f << T -> Window >>(x : Window)
NOTE. Parameters may be suppressed; .
If you have taken the example from an informal source, it is clearly an error. I would forget about it. :)

What are pure virtual methods in UML?

I am attempting to understand how I should use the realization of interfaces and the implementation of abstract classes in UML. I came across the post at https://stackoverflow.com/a/13438187/700543 whereby the poster states that pure virtual methods are interfaces whilst those that are part pure virtual methods are abstract classes. Is anyone able to give me a real world scenario and not one based on code?
An Interface is only a "class skeleton" for library users to extend, and as you said, methods cannot be implemented. An Abstract class can have implemented methods. I will give you a real life example:
Imagine I provide an Interface for people to implement sorting functions and I also provide a Class for bench marking sorting functions. My bench marking class only needs to know what methods of the Interface it needs to call in order to perform the bench marking, it does not know how they are implemented. Therefore, inside the bench marking class you might only see something like sortInterfaceInstace.getNumberOfSwap(), whereas sortInterfaceInstance is only known to be of sortInterface type at compile time, and not of any specific user sort implementation.
If you need implemented methods, use abstract instead of interfaces.
An interface only describes how something can be used, it provides none of the underlying implementation of how it gets done, i.e. a class with only pure virtual functions. An English analogy for an interface may be an adjective.
One example of an interface is a Movable interface. This interface may provide one pure virtual function move which tells the object to move to a given location. However, how it moves there is not implemented.
An abstract class on the other hand differs from an interface in that it provides some of the implementation details, but not all of them. These are conceptually high-level items that can be manipulated in certain ways, but when you get down to it the high-level item doesn't really exists or make sense by itself.
For example, say we have an abstract Shape class. The shape can have a certain origin which can be tracked independent of what Shape it is. The functions to transform the shape can be declared and implemented in the Shape class, saving the hassle of having to provide the same implementation in each sub-class. However, when you try to get the area or perimeter of the shape it's difficult to answer this without knowing more about the shape.

Dissecting java Class file in haskell

I just recently started learning the Haskell language earlier this year and am working on a project that inputs a java class file (i.e FileName1.class) and dissect that file to print out the following:
name of the class defined by the class file
the number of methods of the class, their names and types
I did some research and found that this is possible by using a JVM but am a little lost in the process, anyone have any suggestions on how to tackle this?
You need to write a parser for the Java class format.
Luckily there are already libraries to do that.
Parse the file, inpsect the AST generated, print the required information.
Give parsec a try.
http://www.haskell.org/haskellwiki/Parsec
This is an incredibly good tutorial on how to get started: http://www.haskell.org/haskellwiki/Parsing_expressions_and_statements
And also from Real World Haskell: http://book.realworldhaskell.org/read/using-parsec.html
Parsec even contains a default Java language definition.
http://hackage.haskell.org/packages/archive/parsec/3.0.0/doc/html/src/Text-Parsec-Language.html#javaStyle
Also, when inspecting your AST, you might want to use the Reader monad to keep your type signatures from getting too polluted.

Resources