Tuesday, 26 May 2015

May 26 Lecture

Step 1
Get a certificate that has push notifications on apple.developer

Step 2 
Download p12 file

Step 3
Create a new provisioning profile

Ad Hoc is a type of developer profile.

However, choose iOS development

Step 4
Need to choose the corresponding AppID

Step 5
Download this profile

Step 6
Go to parse. In settings under Push Notification Settings turn on client push enabled.

Add the p12 file in parse

Step 7
Open a project with parse
Set the bundle identifier by looking at the profile created on the apple dev site
Usually com.something

Step 8
In the project settings set the code signing identifier

Step 9
Also set the team in general

Step 10
Set the parse id (Parse.setApplicationId()) to match what is on the parse page. 

Step 11
PFUser.enableRevocableSessionInBackground()

Step 12
var pushNotifications:UIUserNotificationSettings=UIUserNotifications(forTypes: .alert, categories:nil)
application.registerUserNotificationSettings(pushNotifications)
application.registerForRemoteNotifications()

Step 13
var push = PFPush()
push.setMessage(“Test push notification”)
push.sendPushInBackground()

### Facebook
Step 1
Facebook developer page
My Apps
Settings
Make sure that the Bundle 


Monday, 25 May 2015

May 25 Lecture

this week=tinder clone
push notifications, Facebook graph, geopoint, on may26

storyboards useful here

swift gesture recognizers
Selector(“wasDragged”)
for labels userInteractionEnabled is false by default. Have to set it to true

add func
func wasDragged() {
    print(“dragged")
}

wasDragged(gesture:UIPanGestureRecognizer)

summary
Two things taught
First, UIPanGestureRecognizer
Second, transforms
CGAffineTransform
CGAffineTransformMakeRotate
then there are 3 things
  1. apply the transform
  2. apply the inverse transform at the end

Friday, 22 May 2015

May 22 Lecture
mix and match

storyboards + spritekit + segues
can use SKviews in sprite kit
embed UIViews and modify them in UIViewControllers 

network calls
For example, can launch an analytics call inside a closure using SKAction.

note
drag container into storyboard creates an embed segue

to have a close button
work inside of prepareForSegue
minimize 

-chained animation
animations created with UIView.animateWithDuration can be chained by putting further animations into the completion block


why use a weak reference for the container outlet?

Thursday, 21 May 2015

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?

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
  1. using a primitive where you should be using an NSNumber
  2. using an NSNumber where you should be using a primitive
terminal
"no next tag press return"


Sunday, 17 May 2015

May 16

bug
moveVertByIdAndDrawGraph - the moveVertById method is not working on self.graph
issue
You can only send objects in performSelector: withObject: .  To be more accurate you can only send variables of pointer type.
issue
The selector name is wrong. The compiler will give a warning for this but it will still run. 
note
Changing methods that are called in delegates in a lot of work. You have to change the method name in the implementation, the header, and the protocol definition. This would go faster if I could ever remember the command to switch between header and implementation. 
issue
Both the view controller method and the view method are out of date.
note
We have to set the viewId and pass the view id back
setting the view id occurs in the ViewController
passing the view id back occurs in the 

-(void)drawGraphAfterMovingVert:(int)viewId toXPos:(NSNumber*)endX toYPos:(NSNumber*)endY;
is this the right thing that I should be moving ?

note
in iOS there is no such thing as performSelector: withObject: withObject withObject: . two withObjects is the limit. 
question
is drawGraph getting hit after a move
answer
yes 

question
is removeSubviews getting hit
answer
removeSubviews is a graphWorldView method

issue
currently one of the breakpoints is just “setup”
goal
I want the graph cat to save. 
question
is the graph cat currently getting executed ?
answer
yes

it is sufficient to have parse save each of the verts
question: is the for loop in save in the Graph cat currently getting executed

bug and resolution: my save method in the PFVert class was not getting called because of a namespace collision.
style
Calls into my subclasses of PFObject should originate from PFVert

question
is blocking of saves of data that already exists in parse working ?

I can see from Parse that the Parse data model is not getting updated after I move a vert.
Question: is this happening because getVertById is returning nil ?
Answer: no. getVertById is returning a vert

note
When you write an NSLog statement it will always feel like you don’t need to write what method its in - after all its only going to be there for testing. 
goal
what I need is visibility into the number of Parse saves that get done. 
I can generalize this goal. 
note
Use __block variables to share storage.
bug
async issue
For some reason when I attempt to get the value of count I get out zero.
note
Apple's “debugging new in Xcode 6” from 2013 is way over my head.
day summary
I got changing the model to work.

GOT ASYNC PROBLEMS