Sunday, June 15, 2014

Storyboard and Segue


On interface builder, it almost looks like 2 nibs same time with transition in middle (known as segue) .
You specify in code what you want to make happen. On the right side of scene you can see transition details : identifier: ShowAlternate, type is Modal, FlipHorizontal. There is an action on button inform Destination Controller that delegate will be self

src3.pdf on page 32:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
 {
if ([[segue identifier] isEqualToString:@"showAlternate"]) {
[[segue destinationViewController] setDelegate:self];
}
}

storyboard-and-unwind-segue

with storyboard you can have multiple views on a same board. It introduces segues. Segues represent transitions between screens. Opening a storyboard and your have pretty good idea of the UI flow at a glance.


Tuesday, June 10, 2014

Javascript hoistology



Scope and Hoisting explained
  • Unlike most programming languages, JavaScript does not have block-level scope
  • Variables have either a local scope or a global scope.
  • If you don't declare your local variables with the var keyword, they are part of the global scope
  • All variables declared outside a function are in the global scope. In the browser, which is what we are concerned with as front-end developers, the global context or scope is the window object
  • a variable is initialized (assigned a value) without first being declared with the var keyword, it is automatically added to the global context and it is thus a global variable
Only functions create new scope
http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html

JavaScript Declarations are Hoisted - variable used before its declared. JavaScript Initializations are Not Hoisted -  http://www.w3schools.com/js/tryit.asp?filename=tryjs_hoisting1


http://yehudakatz.com/2011/08/12/understanding-prototypes-in-javascript/
If a value is enumerable, it will show up when enumerating over an object using a for(prop in obj) loop. If a property is writable, you can replace it. If a property is configurable, you can delete it or change its other attributes. 
var person = Object.create(null); 
Object.defineProperty(person, 'firstName', { value: "Yehuda", writable: true, enumerable: true, configurable: true });



hasownproperty-vs-propertyisenumerable
The propertyIsEnumerable method returns true if proName exists in object and can be enumerated using a ForIn loop. The propertyIsEnumerable method returns false if object does not have a property of the specified name or if the specified property is not enumerable. Typically, predefined properties are not enumerable while user-defined properties are always enumerable. The hasOwnProperty method returns true if object has a property of the specified name, false if it does not. This method does not check if the property exists in the object's prototype chain; the property must be a member of the object itself.

Every function has these methods you can call (Object.getOwnPropertyNames(Function.prototype)):
  • toString
  • call
  • apply
  • length
  • name
  • arguments
  • caller
  • constructor
  • bind

http://www.codelord.net/2014/03/14/please-use-hasownproperty-short-story-of-a-hack/



http://www.akhildeshpande.com/2012/09/javascript-prototype.html#more


Saturday, June 7, 2014

Linkery from WWDC 2014


The WWDC keynote - analysis  (http://www.macvoices.com/wordpress/episodes/http://www.twonerdsflipout.com/wwdc-2014/

Note that at the 1:43 mark is when Swift is mentioned:
  • xcode 14 million downloads
  • objective  C has served for 20 years, but what if we did it without baggage of C - "did more than think of it"
  • swift - fast, modern, interactivity
  • type inferences, closures, generics, multiple return types, name spaces
  • native to cocoa same lvm compiler, same arc memmory management, same run time
  • work beside objcective C in same application
  • Use of "playgrounds" within Xcode - running code as you write it showing sidebar, can see imagefunctional - closure  on array elements
  • language guide (Swift eBook) and reference implementation available

Swift Kick in Head
  • Swift is like JavaScript in that a line break is enough to mark the end of a statement, and ending them with semicolons is optional
  • Swift associates types with variables. The compiler infers the variables’ types from the values assigned to them
  • Int, Float, Double, Bool, (whose values are true and false as opposed to Objective-C’s YES and NO) , String - forcing a Float type for what could be a double if type not specified -  var someValue:Float = 3.0
  • function definition example: func circleArea(circleRadius: Double) -> Double
Getting started with Swift


swift programming language intro

  • Playgrounds that allow you to experiment Swift and see the result in real-time. In other words, you no longer need to compile and run your app in the Simulator. As you type the code in Playgrounds, you’ll see the actual result immediately without the overheads of compilation.
  • Swift allows you to use nearly any character for both variable and constant names. You can even use emoji character for the naming
  • strings are represented by the String type - Whenever you assign a string as variable (i.e. var), the string can be modified in your code
  • Swift allows you to compare strings directly by using the == operator
  • Objective C you use the addObject: method of NSMutableArray to add a new item to an array. Swift makes the operation even simpler. You can add an item by using the “+=” operator
  • Swift only provides two collection types. One is arrays and the other is dictionaries.
  • You can define classes in a single file (.swift) without separating the external interface and implementation
  • Swift requires you to provide the default values of the properties or a ?.

Swift for scripting

Swift Flappy birds four hours



http://stratechery.com/2014/steve-jobs-wouldnt-done/

The Alt Conference - http://www.altconf.com/

Casa De Mora

http://daringfireball.net/thetalkshow/2014/06/06/ep-083

http://kpbp.github.io/swiftcheatsheet/

http://www.cnet.com/news/apples-swift-explained-what-it-is-and-what-it-means/

https://developer.apple.com/videos/wwdc/2014/

http://inessential.com/2014/06/06/early_thoughts_on_wwdc_2014

Adding Juice

https://github.com/fullstackio/FlappySwift

http://www.cnbc.com/id/101728354

https://gist.github.com/jonathanpenn/c69e7b8485e29ffff598

Cloud services

http://www.designntrend.com/articles/14812/20140602/wwdc-2014-what-reveals-apple-goals-comparison-google.htm



http://www.iphonelife.com/blog/31369/wwdc-2014-7-huge-ios-8-advancements-app-developers

http://blogs.vmware.com/euc/2014/06/ios-8-huge-hit-enterprise-new-features-management-productivity-security.html

http://9to5mac.com/2014/06/03/ios-8-webkit-changes-finally-allow-all-apps-to-have-the-same-performance-as-safari/

Friday, June 6, 2014

Javascript this and call that

The essentials video on 'this' says: " this refers to owner of the function we are executing or to the particular object the function is a method of." http://quirksmode.org/js/this.html

Here is one of simplest programs but it demonstrates the 'this' in two different uses:
var MyFunction = function () {
        console.log(this);
       
    }

MyFunction();
var obj = new MyFunction();

From each of the invocations, the two console outputs look like this:




Now, we have added a local function tryme() to MyFunction(). Again, it starts out by executing line 35 without a variable defining it.

















Since tryme() gets invoked without a variable assigned to it, we get the global this object. Likewise, when MyFunction() is invoked without a variable assigned to it, we get the global object.


Then, with a var obj getting  new MyFunction(), we have MyFunction owner of this, but inside tryme we get default value of this (i.e. window)


Now on to prototypes , its is an object in which other objects inherits properties.
Note that every object has a __proto__ in the debugger. Here is what it provides:









The prototype says if i do not have the property or method that is being requested, go to the 'object' that this field references and look for it.





















After highlighted line executes displaying f



Here we refdefine the class and instead have a prototype method for setName:
var MyFunction = function () {
this.first = 'chris';
this.last = 'cross';
    }

var f = new MyFunction();
MyFunction.prototype.setName = function (_first, _last) {
 this.first = _first;
 this.last = _last;
};

f.setName('cross', 'court');
console.log(f.first);
console.log(f.last);




First: (FROM http://jsfiddle.net/vzFT2/2/):







This value at line 54 before executing the call (global object of window):



Then we step into call at line 54:










the output of line 58 with the hello for property2 (the local_fn.call() populated this as the passed in method):



throw is executed on line 49 which is caught on line 57, line 63 is next function called and this from line 61 has global object:


http://devlicio.us/blogs/sergio_pereira/archive/2009/02/09/javascript-5-ways-to-call-a-function.aspx

http://tech.pro/tutorial/2010/functional-javascript-part-3-apply-call-and-the-arguments-object

 Object.getOwnPropertyNames(Function.prototype);


var MyFunction = function (name, color ){
   var b =  {
  this:this, 
  name:name, 
  color:color
}
console.log(b);
    }
    MyFunction('ipod');
    MyFunction('ipod', 'black');



"call method: method of a function invokes the function with the context variable this set to the first argument passed in, and then each additional argument is passed into the function"

MyFunction('ipod', 'black');
MyFunction.call(window, 'ipod', 'black');

"apply method:invokes the function with the context variable this set to the first argument passed in. The second and final argument, however, will end up being the arguments of the function provided as an array"

ttp://www.smashingmagazine.com/2014/01/23/understanding-javascript-function-prototype-bind/


http://stackoverflow.com/questions/17017115/javascript-call-function

Thursday, June 5, 2014

Azure-izing

Azure sure is making a name for itself. Here is the Azure 101 , azure overview

mobile services with iOS
Tutorial shows you how to add a cloud-based backend service to an iOS app using Azure Mobile Services

Notification Hubs

Azure Notification Hubs makes it easy to either add push notifications to existing iOS apps or enhance your current push strategy, regardless of where your app backend is hosted or what language it's written in. 

Few folks with iBeacon experiences

How i tracked house movements...
Next, I wanted to see if I could track movements in my own house as a simple test, without creating a custom app. I looked for a few apps that could detect the iBeacons and execute an action. There are a few apps capable of doing this – all of them somewhat limiting. The only app I found that allowed me to control what happens when triggering an iBeacon was an app called Placed.
Coding for iBeacons
One limitation iOS has, versus OS X and Android, is the inability to listen for iBeacon regions indiscriminately. The application must explicitly request monitoring for each and every UUID it is interested in hearing about. This is no doubt better for the user’s battery, but isn’t really spelled out clearly in the docs.

Monday, June 2, 2014

WWDC sampling from interwebs

The Keynote...

The  musical

HealthKit , Cloud, ...

Chris "For now, it’s going to be able to live alongside existing Objective-C code however, I fully expect that it’ll become the standard; either from developer adoption or by Apple eventually forcing everyone to use it"

iOS8 Family Sharing, et al..

Mac 10.10 Yosemite:

  • Improved Notification Center 
  • Improved Spotlight - can also show additional info from the Internet as well as third-party applications
  • SMS and call support
  • meshed iOS and Mac OS X into one
  • iCloud Drive with sharing
  • you annotate and scribble on images or PDF files without third-party sw
  • Safari smart search field and suggestions, along with improved tabbing
  • sync files and communications between the mobile and desktop OS with handoff

iOS 8 and Yosemite available for developers

Swift : https://developer.apple.com/swift/ [integration guide]

http://www.technobuffalo.com/2014/06/02/apple-swift-programming-language-unveiled/

http://www.technobuffalo.com/2014/06/02/apple-swift-programming-language-tools-now-live/

http://www.technobuffalo.com/2014/06/02/ios-8-find-out-if-your-device-is-supported/

Keynote live blog

iOS8 news

Home automation

New photos app iOS8

Family sharing