Tuesday, 30 June 2015

june 27
segmented control is not working

Segmented controls work for buttons but look ugly.

Found out that it is possible to have multiple buttons on a nav. Was confused for a long time because there is apparently no good way to make multiple buttons in storyboard. (There are some ugly hacks.) Yet multiple buttons is trivial in code. 

Lesson: storyboards only ever offer a curated selection of the features that are used most often and are easy to set. 

note
keep track of what input is given in completion handlers

test
see if MailGen is now working (except for saving Draft obviously)

is nice

changed protocol.
now the cancel button doesn’t work.
do i enter didFinishWithResult ?

oddly if I put a breakpoint into didFinishWithResult then it crashes but no breakpoint == no crash

ok 
now header files should display the right date

reminder:
we cannot print out array in the debugger

attempting to print out an *optional* array results in the weird error message “Array index out of range”

q
why are there 12 Vert objects?

q
why are the managed objects in core data appearing multiple times ?
possible reasons
  1. fat finger
  2. test code gets run before everything and adds its own elements

I don’t see how testing could do this…

q
If I clobber the file does this change to 4?
ans
yes

note
using an optional type where an optional is needed will potentially cause failure

q
Why did it get changed to optional when I already it working as non-optional ?

result
turns out that the main problem was that I was assuming debugging output would be valid. Debugging output is garbage. 

note
only a single window is used to present content on the screen (it is an example of a singleton in IOS) and the app delegate has access to it. 

note
have many debuger launch failures today

note
root view controller is not equal to the view controller that gets presented at launch.

note
storyboards confuse the issue of initialization and class construction.
The only storyboard element that gets an init is the root view controller.
All storyboard elements are visual representations of classes. They are templates. 

note
instantiateViewControllerWithIdentifier

q
Clearly saving sometimes works for some things.
It could be that:
saving works on all properties but only the first time I do it
saving works only on some properties but does so every time I call saveContext()

I want to look at the x,y positions before and after manipulating the graph to help me decide which is true.

This failed of course because the problem is that the graph is always started in the same place.

note
Don’t assume what is given by apple will actually work. It might be something that worked at one time but the recent changes have broken it. 

note
the problem seems to be that hasChanges is false; I’m double checking that however

note
the problem is that the contexts are different. So I will set a point to see the call stack when this change happens.

the reason that multiple contexts were being created is that I was instantiating the thing in app delegate. It is easy to instantiate multiple copies of a class and then reference the wrong one. 

problem 
Sometimes it is not possible to close a running instance in xcode. 

note
start treating the build button like a resouce. Hit it less. Sometimes swift compile is reasonable but it can be deathly slow i.e. 1 minute for a minor change. 

note

added a breakpoint to test if no savedUsers are found

Saturday, 27 June 2015

June 2

q
need to understand initializers

issue
use of undeclared type UIViewController

q
where can I get a short list of the required initializers

note
whenever swift gives a weird error you should first go to the documentation

q
nothing happening on screen.
is barButtons getting hit ?

q
which of the view controllers init methods is getting triggered ?

task
with a runtime error need to find where the error took place.  First step is always an exception breakpoint

note
Whenever a runtime exception occurs the first step to solving it is to use an exception breakpoint.

q
In swift how to create a method that does not have named arguments ?

q
check if I can get ANY graph method to work
result
No. I created a method with nothing in it and it does not work. 

q
If I create a graph variable within testGraph does it run?

result
somehow the build target got changed

other interesting ways that this bug can occur are given here

june 21

issue
the send button is not dismissing the viewController

issue
  1. go to email
  2. press cancel 
  3. press delete draft
  4. go to email again
  5. press cancel

nothing happens. 

q
On the second cancel do we enter didFinishWithResult
ans
no

does setting the delegate to nil help?

note
testing if the delegate can be set to nil

note
what I really need is a way to send email automatically

note
title is objectiveC style so must be assigned before use. 

breakpoint and look at the title we are trying to assign

note
the notation for blocks as input is often (() -> Void)

bug
adding vert is not working 

changed startPos to restart and still not entering

note 
the scrollview has several subviews.
Have to send the buttons to be behind GraphWorld View or they block gesture recognition. 

note
remove verts not working

bug
UITextField cannot enter text

task
want the entity name to appear each time the attributeTable gets loaded

note
text is not being displayed after being set. Does it display at setup?

note
can’t deselect a cell after it is selected. 

note
check if the gesture recog blocks pans from occurring

bug 
"The working copy “CoreDataModeller” failed to commit files”
fatal: “WIll not add file alias MailGen.swift … mailGen.swift already exists in index

bug 
attributes are not given deterministically

refactor 
cells will contain the text of the default string for attributes. This is fetched by 

is UIKeyboardDidHide note entered?

issue
the keyboard is not dismissed.

q
is this a problem with note center ?

note
trying to find why verts have no attributes
set bpoint in testGraph()

note
instead of having a list of strings have a list of attribute objects.

so ditch attrStringsOrNil ?
yes.
it was silly to have it in the first place

ok, that will complicate some things. I will need a sort function that  can handle attributes. fine 

note
writing orNil at the end of a variable name is silly. It is easy to check if the variable is optional using alt. 

note
do I expect it to work as it is?
what have I done?
the observers have been added
the responses have been added
the array sorting is done 

tests
what I would like to test?
I want to make sure that the array can be sorted

cells are setting titles but not types. 

Future Tests

Check that the name of the .h file is the same as the name of the entity.

Sunday, 21 June 2015

june 20

q
What are the inits for UIPickerView

issue
email class was not working with an "unrecognized selector" message or something like that.
solution
check the import statements:
need to use import MessageUI

note
There are several things that need to be done in order to present a view controller programmatically. See apple docs. But the main step is

func presentViewController(_ viewControllerToPresent: UIViewController,
                  animated flag: Bool,
                completion completion: (() -> Void)?)

note
for some reason tried to use the following to convert a string to an NSData
NSData* dataFromString = [NSKeyedArchiver archivedDataWithRootObject: aString]

note

sending files by email sometimes does not occur < a minute as it should. Often it is much faster but the worst case time is a problem. Opening the mail app seems to force an update. 

Saturday, 20 June 2015

June 19

Five refactors to do
1
tapping. 
There is no need to have tap recognition in GraphWorldView.

2
get rid of all calls to pointInside() like this one:
(x as! UIView).pointInside(loc, withEvent: nil)

3
issue
my tap gestures are not getting recognized.
I turned off tap gesture recog on the the scroll view in its init
However, I may have left tap gesture recog turned on
Fond it. I am turning off all recognizers in moveMode()
What’s holding you back is rushing. Don’t assume.
4
remove gridBack from CoreController
5
add the buttons as a subview of the scrollView.
this could take 45 minutes
have 11 right now
last thing done: wrote a helper method

summary
Morning: I struggled with adding an image in the middle of another view. 
Afternoon: fixed the buttons so that they would be dispalyed on the scroll view. 
Took some time to understand that

  1. the problem was view order
  2. there was no way to fix this without reassigning a parent view of some other views. The methods sendSubviewToFront and sendSubviewToBack are weak tools, they only change the position of entries in the subviews array and trigger a redraw. If the given input view is not in the subviews array they will fail silently. 

Monday, 15 June 2015

june 14
task
set the image background of GraphView to be the grid

probably there is a property that says that images of UIScrollView must scale to fit. 

q
do we enter the double loop in drawGraph ?

q
does the context provided deleted objects just for convenience or do we really need it ?

q
is getIntersectingVert running
a
yes

q
Are both the cases of hitting and not hitting being treated correctly?

issue
we are not having vert collisions

task

method to get current state

Wednesday, 10 June 2015

June 8 2015

Cannot invoke getVertViewById with an argument of type Int32
lazy may not be used on an already-lazy global

note
swift: dealloc is now deinit

“graph does not have a member named moveVertById”

Currently working on GraphExtension
4 errors in GraphExtension = 10 mins

fix moveVertById. 
a 3 argument method that is supposed to be called on graph.

note
it is safer to have 

note
do not expect the compiler to fare well when you try to do advanced things like adding two numbers within a method call

note
In objective C you can only ask an object “Is your class X?"
In swift you should be able to ask an object “what is your class?”
but I have never actually done this.

for some reason circSize and edgeSize are not CGFloats

8:30pm
currently working on VertView

note
when you see code you need to see it in tandem with the markers 

note 
what is the type of array.count

note 
With value types there is usually no good reason to use as!. 
Instead you instantiate one value from another. 

task 
modify moveVertById

note
working inside graphWorldView

note
You will never be harmed by making all data an optional variable.

task
check if drawEdges is getting trigged.
result
yes

task
check if X1<X2 is getting triggered
result
the error was that I was checking if v and w were in the same place rather than in different places

problem
only three of the four verts are being drawn

task
examine the breakpoint set after edgeFrame and see how many times it gets hit
1

fact
when an observation of a vert is made the finishedObservedMethodFlag has been set on that vert. 

fact
Four observations are made for the test graph. There are 3 ways that the method could fail to work. The keyPath could be wrong. The graphView could be nil. The views of the vert might not be fresh. 

fact
all the verts have working key value observers. 

task
remove the print statements that are being used.
results
the print statements are not in GraphWorldView

issue 
edge view is nil in drawEdges2

task 
add logic to prevent edgeViews being set as not fresh if there are no edges in the vert.
This will happen in Edge cat.

done
there is now a breakpoint right after the edgeView call. 
There is one within the edgeView as well but within the loop.
If we don’t get to this breakpoint I can be certain that’s where the problem is. 

note
there is no good reason for using auto-unwrapping. 

note
after removing auto unwrap from e I have not solved the problem.
I am point inside of the else block

done
removed setNeedsDisplay on addVertAtPoint

note
in some more advanced swift frameworks the type used in objective C will be different. Often you pass in a string instead of just the name

note
think the problem is 
(1) EdgesViews being drawn after VertViews so 

(2) that I was not pushing the view back in the