Analysis of array allocation and address

table: 0x100700000
*table 0x0

(table+1): 0x100700008
*table: 0x0

custom navigation button

A row of buttons with spacers in between

Requesting what you need, and getting what you want

How to achieve loose coupling

original article on why loose coupling is needed
http://martinfowler.com/articles/injection.html

how to achieve loose coupling in iOS
http://code.tutsplus.com/articles/design-patterns-delegation–cms-23901

If you do not do this…this will happen

https://blogs.msdn.microsoft.com/scottdensmore/2004/05/25/why-singletons-are-evil/

How we achieve loose coupling in Events App using protocols

In detail: UIViewController to Module

Make sure you conform to RecentActivityViewInterface so that you can receive data from delegate methods.

Then create a delegate that conforms to RecentActivityInterface so you can call methods that you need.

ViewController.m
Implement the delegate method so we can receive the results:

ViewController.m
Hook everything up

Then use it like so:

Pass data from UITableViewCell to UIViewController

http://stackoverflow.com/questions/9005052/recipes-to-pass-data-from-uitableviewcell-to-uitableviewcontroller

Solution: Use custom delegate

UIViewController

MyViewController.h

MyViewController.m

Custom table cell and Protocol

MyTableViewCell.h

MyTableViewCell.m

azure permissions

When you are in Active Directory, it will tell you what kind of Role you have:

Global admin
Billing admin
Service admin
User

MY_ROLE-Global_Admin

EPAM_ROLE-USER

I have found that apps created by Global admin can access the GRAPH API. For example, a user from the Tenant’s Active Directory signs in, and then hits the Graph API to access their user data such as first name, last name, address, email…etc.

data-received

If you are a Global Admin, and set up the app, users of this app will have permissions to view their own data.

If you are NOT a Global admin, any app you set, will not have permissions to access Graph API.

VIPER Part 1 – Dependencies, Root Wireframe, AppDelegate, ViewController

demo for xCode 7.3

This tutorial shows how to hook up an AppDelegate, Dependencies object, a Root wireframe, and a standalone ViewController in a VIPER design pattern.

AppDelegate.h

Standard AppDelegate with the window property.

AppDelegate.m

AppDelegate allocates a Dependencies object. That dependencies object will then install a RootViewController onto the Window object.

Dependencies

The dependencies component has a property wireframe. This wireframe is what carries the logic of showing which ViewController. The ViewControllers are simply instantiated and used by the wireframe.

AppDependencies.h

The installRootViewControllerIntoWindow method simply passes along the window object, and let’s other wireframes (or itself) set view controllers on the window

AppDependencies.m

We simply instantiate a ViewController, and then passes it along into the RootWireFrame object so it can do its logic of showing which controller in the window

Wireframe carries logic of showing ViewControllers/Views

RootWireFrame.h

RootWireFrame.m

Using protocols to have components talk to each other in iOS Design Pattern

https://www.objc.io/issues/13-architecture/viper/

Protocol is a one to one relationship where a receiving object implements a delegate protocol. A sending object uses it and sends messages (assuming that those methods are implemented) since the receiver promised to comply to the protocol.

First, the Interactor protocol!

The interactor is the middle man between data and the presenter. It has a protocol that says

1) there is an input property from the presenter that forces Interactor to implement findUpcomingItems ( to find upcoming certain (decided by presenter) items or data.

2) there is an output property pointing to presenter that forces Presenter to implement foundUpcomingItems:.

InteractorIO.h

present_interact

Presenter.h

Presenter.m

Using the interactor property to force the Interactor component to implement required method(s)

The interactor property is connected to the Interactor component. Our interactor property (which conforms to InteractorInput), promises that this Interactor component will have the method findUpcomingItems implemented. Thus, say when we want to update the view, we tell the interactor component (through our id interactor property) to call the findUpcomingItems method.

In other words, Interactor can retrieve data for us because it talks to the DB Manager/Entities, thus, we (the Presenter) have an interactor property to the Interactor object so that we can call required Protocol methods to find certain data for us by forcing the Interactor component to implement findUpcomingItems:

Presenter component implements promised required protocol methods

Presenter conforms to InteractorOutput because we promise to implement a method foundUpcomingItems: which means we’ll take care of
the data returned by the Interactor.

The Interactor will point a output property to the Presenter. Thus, the output says Presenter must implement foundUpcomingItems:.

Interactor.h

The Presenter object works with the UIViews/UIViewControllers to display data, thus, we point an output property to
the Presenter object in order to force it to implement foundUpcomingItems:(NSArray*).

The method gets gets the found data
in Presenter, and thus, can have the UIViews/UIViewControllers display it.

Interactor.m

Interactor conforms to InteractorInput, which means we promise to implement a method called findUpcomingItems.
This is be requested by the Presenter/Views throug Presenter’s interactor property.

Hooking it all up

Interview Exercise – Earliest Index of array, where the subarray contains all unique elements of the array

Time: 2 hours

Try to solve the following exercise in O(n) worst-case time complexity and O(n) worst-case space complexity – giving a more complex solution is also acceptable, but not so valuable.
Also, try not to rely on library functions, unless they don’t increase complexity.
Please test your solution – correctness is important.

You get a non-empty zero-indexed array parameter A that contains N integers. Return S, the earliest index of that array where the sub-array A[0..S] contains all unique elements of the array.
For example, the solution for the following 5−element array A:
A[0] = 3
A[1] = 3
A[2] = 2
A[3] = 0
A[4] = 2
is 3, because sub-array [ A[0], A[1], A[2], A[3] ] equal to [3, 3, 2, 0], contains all values that occur in array A.

Write a function
function solution($A);
that, given a zero-indexed non-empty array A consisting of N integers, returns this S index.
For example, if we call solution(A) with the above array, it should return 3.

You can assume that:
· N is an integer within the range [1..1,000,000];
· each element of array A is an integer within the range [0..N−1].

//whiteboard logic
15:20 – 16:03

//coding in up in C++
16:03 – 17:29

1st try, O(n^2)

Further thoughts

We can first use a merge sort O ( n log n ) to sort the original array.
After sorting it,you do a O ( n ) run through to build your unique array.

Then, you can build your unique array with O ( n log n ).