Skip to content

Instantly share code, notes, and snippets.

View 98chimp's full-sized avatar

Shahin Zangenehpour 98chimp

  • Vancouver, BC, Canada
View GitHub Profile
@98chimp
98chimp / Answer to Questions
Last active August 29, 2015 14:17
Week02 - D06 Questions
PART I
Q1. A.
MVC is perhaps the most prominent form of structural design pattern used by developers of iOS apps. The term MVC stands for Model-View-Controller with each word representing a key component of this design pattern. Model refers to all aspects of data representation and the logic for data manipulation. View refers to the visual layout of display elements as well as UI elements with which a user can interact (e.g., buttons, sliders, etc.). In the MVC construct, Model and View are to have no direct communication with one another and all responses to user input are to be coordinated by the controller which sits as an intermediary between Model and View. As such, the Controller can have a two-way communication with each Model and View independently from each other, and continue to play the crucial role of relaying user input for access to specific data and conversely coordinating the display of the data in the desired form in the View.
The implied purpose of this design pattern is that by having cle
@98chimp
98chimp / Answer to Questions
Last active August 29, 2015 14:17
Week02 - D04 Questions
Q1.A.
Q1.B. i) Any number of objects may receive the notification, not just the delegate object. This precludes returning a value.
ii) An object may receive any message you like from the notification center, not just the predefined delegate methods.
iii) The object posting the notification does not even have to know the observer exists.
Q1.C.
Q2. This code will maintain a strong reference to self which leads to a strong reference cycle and poor memory management. To avoid this problem, the code can be modified as follows:
[self setMySexyBlock:^{ [__weak self mySexyMethod]; }];
Q3.
@98chimp
98chimp / Answers to Questions
Last active August 29, 2015 14:17
Week02 - D03 Questions
Q1. Part I = d;
Q1. Part 2 = a;
Q2. The App Delegate will:
- monitor the presence of a touch event;
- detect a touch event;
- record the (x, y) coordinates of the touch event;
- correlate the touch coordinates with the bounds of all existing views;
- determine the a match between the touch event's coordinates and the bounds of a specific view;
- identify that view as the item touched on the screen;
@98chimp
98chimp / Answer to Questions
Last active August 29, 2015 14:17
Week02 - D01 Questions
Q1. First, the view component of the MVC (i.e., LLView) should not be declaring a property that is of UIViewController type
(i.e., @property (nonatomic, weak) UIViewController* parentViewController;). Instead, the LLView should have a protocol that is potentially delegated to UIViewController in order to achieve separation of concerns. Secondly, the method to configure the LLObject appears to be stting up the model and as such it needs to be declared elsewhere to separate Model from View altogether.
Q2.A.i) atomicity (i.e., atomic vs. nonatomic) deals with how properties behave in a multi-threaded environment. To avoid potential data curroption resulting from the de-coupling of the getter and setter methods for the property, the use of an atomic attibute for a property is advisable. Conversely, in a single-threaded setting the nonatomic attribute is often used.
Q2.A.ii) Weak vs strong: The strong attribute creates an owning relationship to whatever object is assigned to the property. This is the implicit beh
@98chimp
98chimp / Q3 & Q4
Created March 12, 2015 07:00
Reading Assignment
//
// temp.c
// Adventure Game
//
// Created by Shahin on 2015-03-11.
// Copyright (c) 2015 98% Chimp. All rights reserved.
//
#include <stdio.h>
@98chimp
98chimp / Incomplete
Created March 12, 2015 06:18
Adventure Game
//
// main.c
// Adventure Game
//
// Created by Shahin on 2015-03-11.
// Copyright (c) 2015 98% Chimp. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
//
// main.c
// Linked Lists
//
// Created by Shahin on 2015-03-11.
// Copyright (c) 2015 98% Chimp. All rights reserved.
//
#include <stdio.h>
#include <stdlib.h>
@98chimp
98chimp / Parts 1 & 2
Last active August 29, 2015 14:16
Fibonacci
//
// main.c
// Fibonacci
//
// Created by Shahin on 2015-03-11.
// Copyright (c) 2015 98% Chimp. All rights reserved.
//
#include <stdio.h>
@98chimp
98chimp / Pointers
Created March 11, 2015 20:43
Pointer (Drill)
//
// main.c
// Pointers(drill)
//
// Created by Shahin on 2015-03-11.
// Copyright (c) 2015 98% Chimp. All rights reserved.
//
#include <stdio.h>
@98chimp
98chimp / Game
Last active August 29, 2015 14:16
Guessing Game
//
// main.c
// Guessing Game
//
// Created by Shahin on 2015-03-10.
// Copyright (c) 2015 98% Chimp. All rights reserved.
//
#include <stdio.h>
#include <stdio.h>