May 21
q
With sprites is there any way to have position be a corner rather than the midpoint
Reading about operators on NSHipster
Compound statements
q
How is the override statement used in swift ?
note
it seems like the only way that core should be changed is through key-value observing.
q
does my core controller class start listening when the class is initiated ?
q
are protocols passed by inheritance
note
there are 2 ways that verts should be created. The first way is when we make verts for testing. In this case they are created by choosing a position. There are no animations.
The other case is when they are
note
when I am done with the setupVert I will need to check that drawGraph has been removed everywhere
bug
my buttons are not displaying
the method barButtons is getting hit
bug
not able to change the model .
q
I am entering setDrawn somehow.
there is a bug on drawn
#
debugging first questions.
how often do we come to the point of the error
so this would mean walking over the error messages and printing drawnNum for each of them
q
could it have something to do with the internet connection?
q
is setupVert used in the wrong place somewhere.
Or there is a core controller setupVert and one inside the vert itself. Is the wrong method being called?
q
is this a race condition created by the current call to drawGraph in onNewGraph ? drawGraph tries to access the variable before core data has saved it.
note
no. the bad call is originating in invalidate.
note
one issue with key value observing is that if you are observing several properties you will end up triggering many observation events. The problem with that is that observation events will be triggered before you have finished changing all the properties.
I don’t know how to tell the view controller to wait until all the properties have been changed before responding.
q
I did not observing on all the properties so why is invalidate getting called so often … ?
issue
vert is no longer getting invalidated after a move
test
see if I am ever remove outdated views
q
why is drawEdges not getting called at the right time ?
#
The main problem I have with key value observing is that often you want to observe the completion of methods rather than changes in values. What do you do in this case?
METHOD 1 Just add a property
didFinishObservableMethod in the class. Observe this property. At the end of every observable method we should set this property to be true.
This kind of fucks you if your goal is to work with core data because you need to rebuild the model once again.
METHOD 2 TOUCHING
A brutal hack that achieves the same goal is just adding observedVal=observedVal at the end of every observed method.
A problem with the brutal hack is that it does not work on class methods.
wrong idea about solution
You could add a class method touchObservedData to get around this.
reason
Class methods can only call class methods.
review question
Why does core data use @dynamic ?
#Data Model laundry list
Remember to change the parseObj
Idea
Class methods are simply an unwise idea. They exist only because of the following mantra “In OO everything is objects and so classes are objects”
q
Are we entering the neighboursDrawn method ?
Task 1
Get verts drawing
Task 2
Get edges drawing
#
What happens to my invalidation code?
Shouldn’t it occur in vert
test
check if the newX and newY passed in are good
result
moveVertToX: toY is not getting called
bug
have a line v.self.vertViewId. I don’t know why this doesn’t generate a compiler error
bug
getVertViewById is always returning nil
v.vertViewId
the id
note
NSNumbers are dangerous and horrible because of pointer assignment.
vertViews are now getting assigned.
Now is getVertViewById getting anything ?
q
is the list of verts empty ?
q
is po working correctly?
a
yes. po does not work on NSNumbers.
test
the problem could be with the vertViewId of v ?
result
vertViewIds are now working on core objects
question
vertViewIds working on views ?
question
is vertViewId getting set after the vert is allocated and init
question
is the vertView found by getVertViewById nil or not
question
back to basics. when is the key path getting matched
question
what is expected
When testGraph is being created all the vertViews found by getVertView will be nil. This will result in views being alloced.
what is happening
The method is entered 8 times.
vertView is nil 4 of those times.
drawn is set to YES 4 of those times. probably wrong.
issue
moveVertToX is not getting called after a move
the problem could be that one of the args in drawGraphAfterMovingVert is nil
issue
I am passing a nil vert into the graph method moveVertById
note
I am being reckless. I should always have been checking the bounds on arrays.
note
the compiler will not throw an error when you do shit like
NSNumber* id
cause
Creating an NSNumber with an incompatible type. I said the thing was an int when really it was a pointer. Boom
Some compiler warnings are lethal.
task
Lets reduce the number of compiler warnings
q
If we turn off setNeedsDisplay in initWithFrame will drawRect still be called ?
q
if we are never supposed to call drawRect then only the system is allowed to set the argument?
// or do we have control of a property to set this?
q
is the problem that fastEnumeration doesn’t actually do a check?
note
if you use a selector you can’t assume its synchronous so you can’t assume that the remainder of the method after the selector call is synchronous either
issue
method definition for touchObservedProperty not found
q
In IOS you can just redraw a view by changing its position
note
unrecognized selectors at runtime are usually the result of not using enough code guards
cause
Creating an NSNumber with an incompatible type. I said the thing was an int when really it was a pointer. Boom. Some compiler warnings are lethal.
cause
The only reason to use NSNumber is that it is an object and some of the nice tools Cocoa provides to us can only take objects as arguments.
In theory use an object instead of a primitive should not be a problem. But having two different “forms” for numbers introduces a pair of possible pitfalls
- using a primitive where you should be using an NSNumber
- using an NSNumber where you should be using a primitive
terminal
"no next tag press return"