Tuesday, April 14, 2015
Saturday, April 11, 2015
Programmatically Creating an iOS Swift Based UITableView and Supporting Detail View
This is a quick tutorial on how to create an iOS Swift based UITableView and supporting detail view. I will also point out mistakes I made along the way and the errors that I came across. I hope that at least one other person in this tiny world of ours finds this blog and is able to avoid the common pitfalls that come with trying to learn something new.
Part 1: Creating the UITableView controller and populating its cells with data from a webservice.
Setting up the app
- Create a new Single Page Application
- Delete Story Board
- Delete ViewController.swift file
- Delete Main from General
Programmatically Create View
- Create new cocoa class > File > New > Cocoa Class
- Change class from NSObject to UITableView
- Don't select "create xib"
- Make sure language is "Swift"
- Name the file EventsViewController
- Open AppDelegate.swift and add the following lines of code:
//
// AppDelegate.swift
// BlogPostiOSUITABLEVIEW
//
// Created by Michael Droz on 11/28/14.
// Copyright (c) 2014 Michael Droz. All rights reserved.
//
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
window = UIWindow(frame: UIScreen.mainScreen().bounds)
//Create an EventsViewController
let evc = EventsViewController(style: .Plain)
//create an instance of UINavigationController
let navController = UINavigationController(rootViewController: evc)
//place nav controller's view in the window hierarchy
window!.rootViewController = navController
//can I delete these two lines?
window!.backgroundColor = UIColor.whiteColor()
window!.makeKeyAndVisible()
return true
}
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
How to add audio to a Swift based iOS app
Setting up the app
- Create a new Single Page Application
- Open the ViewController.swift file
- Add the AVFoundation module to your import statements
- var audioPlayer:AVAudioPlayer!
- if var filePath = NSBundle.mainBundle().pathForResource("file_name", ofType: "mp3"){ }
- audioPlayer.stop()
- audioPlayer.rate = 0.5
- audioPlayer.currentTime = 0.0
- audioPlayer.play()
The following code is a concrete working example of the AVFoundation module that I implement as part of Udacity's iOS Nanodegree program.
//
// PlaySoundsViewController.swift
// Pitch Perfect
//
// Created by Michael Droz on 4/11/15.
// Copyright (c) 2014 Benefakter Apps by Michael Droz. All rights reserved.
//
import UIKit
import AVFoundation
class PlaySoundsViewController: UIViewController {
var audioPlayer:AVAudioPlayer!
@IBOutlet weak var stopButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
stopButton.enabled = false
//get handle on audio file
if var filePath = NSBundle.mainBundle().pathForResource("movie_quote", ofType: "mp3"){
var filePathUrl = NSURL.fileURLWithPath(filePath)
audioPlayer = AVAudioPlayer(contentsOfURL: filePathUrl, error: nil)
audioPlayer.enableRate = true
}else {
println("error retrieving file path")
}
}
@IBAction func playSlowAudio(sender: UIButton) {
audioPlayer.stop()
audioPlayer.rate = 0.5
audioPlayer.currentTime = 0.0
audioPlayer.play()
stopButton.enabled = true
}
@IBAction func playFastAudio(sender: UIButton) {
audioPlayer.stop()
audioPlayer.rate = 1.5
audioPlayer.currentTime = 0.0
audioPlayer.play()
stopButton.enabled = true
}
@IBAction func stopPlayingAudio(sender: UIButton) {
audioPlayer.stop()
stopButton.enabled = false
}
}
Friday, November 14, 2014
Off to the Nerd Ranch
Headed to the Nerd Ranch for iOS development training in Monterey, CA. Will be there from 11/14 - 11/21. I've been reading through the Swift based iOS apprentice tutorials and I am very excited. The iOS development ecosystem has come along way. It's a pleasure to develop for this platform!!
Look me up at the Nerd Ranch, Michael Droz or on Twitter @michaeldroz or GitHub @michaeldroz.
Nerd Ranch:
http://www.bignerdranch.com/
Look me up at the Nerd Ranch, Michael Droz or on Twitter @michaeldroz or GitHub @michaeldroz.
Nerd Ranch:
http://www.bignerdranch.com/
Monday, April 14, 2014
Amazon Interview Question "Writing Sample" ~ by Michael Droz
Amazon Interview Question - writing sample
I recently successfully interviewed with Amazon.com and was offered a senior program management position within their San Francisco engineer lab. As part of the interview process they asked me to submit a writing sample based on their question “What was the most inventive moment in your career?”
Below is my answer: You might find it helpful and interesting.
TagCow.com - Image tagging problem solved
One of the most inventive moments in my career came just as I was about to throw in the towel on a start-up I had founded in 2006. We had been trying to bootstrap a subscription based scanning service for people’s non-digitalife ( mail, old photo albums, children’s art, etc.,) but it quickly became clear that our approach wasn't scalable so my co-founders and I were looking for a pivot. One of the byproducts of the prototyping and business process modeling we had done for the scanning service was a collection of 100,000+ digital images from my childhood. One day I was trying to find some specific photos that I had seen during the scanning of my images and realized that at scale you can’t “browse” your images you have to somehow enable search. This idea of enabling one to search their photo collections kept coming up over and over again during the following weeks. I would want to show a friend or family member a photo but they would grow bored watching me “browse” through my giant collection of photos. I was certain that there were services available to annotate one’s digital images with meaningful metadata and thus enabling one to search against their image collection so I immediately set out to identify this service and solve the problem for myself. What I found would lead me to my Eureka moment.
I did some research trying to find some image tagging solutions and was surprised that such a service just didn't exit. What I found was that while image recognition had come a long way it was still a long way off from being good enough for consumers. The problem was that only computer scientists were working on the problem and they were looking for a completely automated solution but I knew instantly that I could solve the image tagging problem for everyone by combining algorithms and humans! I was already an Amazon Web Service customer and was familiar with the Amazon Mechanical Turk service. I hatched a plan to license a set of image recognition algorithms called Alipir from the University of Penn State and use Amazon’s Mechanical Turk service to train the algorithms and augment the automated tags with tags generated by the human workers. I called a meeting with my co-founders and they instantly loved the idea - we had our pivot and on that night in January of 2008, TagCow.com was born.
Three months later we completed development of a beta candidate. I was tasked with marketing the service which I had thought a lot about in the weeks leading up to our initial launch. We had no funding so I knew a massive and extensive consumer marketing plan was not an option. Luckily, I had recently read Malcolm Gladwell’s legendary book, Tipping Point. So the same night we completed our beta I scoured the internet for our mavens. Immediately I stumbled onto a gentleman named, Thomas Hawk, who at the time owned a blog focused on the popular photo sharing site, Flickr. In his bio he indicated that he currently had over a quarter-million digital photos and was aiming to shoot more than a million in his lifetime - I knew I had the perfect beta tester. I sent him a personal invite to join our little beta program. That same night he attached his massive Flickr archive to our tagging service. Within a few hours we had tagged his entire collection of images. He was so impressed that he phoned his friend Michael Arrington, editor of Techcrunch.com, and raved to him about our service. By midnight of that night I received a text from Michael Arrington asking if I was available for an interview. I knew our service wasn't prepared for the Techcrunch effect so I called my co-founders to discuss a strategy. Before we could complete our conversation I received a text from a friend of mine congratulating me for being on the front page of Techcrunch. The headline read “Image tagging problem solved”, he would go on to describe our service as “magic”. In the coming hours we would sign up tens of thousands of users and tag millions of images. Here’s a link to the article (which Michael Arrington would later edit after he realized we were using Mechanical Turk): http://techcrunch.com/2008/03/29/image-recognition-problem-finally-solved-lets-pay-people-to-tag-photos/
We would be featured in Techcrunch two more times in the coming months:
Continuous Improvement the Core Foundation of Agile ~ by Michael Droz
A blog post about the importance of continuous improvement practices.
Friday, April 11, 2014
Lexicom IS Redux
A placeholder blog for the set of services developed under the name Lexicom IS Redux a company by Michael Droz + others. This is a company inspired and named after my most successful startup Lexicom Intelligent Systems (circa 1996) - see link below.
http://michaeldroz.blogspot.com/2013/11/lexicom-intelligent-systems-by-michael.html
In August of 2012 I quit my corporate job with Visa and struck out on my own again. With a handful of ideas in my bag and a tone of talent supporting me I restarted under the name Lexicom IS Redux. Below are the prototypes and services that I developed under that working name. Unable to attract investment I ran out of money and closed up the company in December of 2013. At least one of these still lives on under a different name and under very capable hands. I won't mention them by name because I have nothing to do with the huge success that team is now on the verge of enjoying - but I was there when the seeds were planted and for me that's inspiring!
I am also still prototyping Helpiado but mostly as an exercise in learning Ruby-on-Rails. I will add links and other interesting artifacts from this experience.
Software development outsourcing: http://www.hitechito.com/
(used them since 2003).
Services Prototypes + Developed:
http://michaeldroz.blogspot.com/2013/11/lexicom-intelligent-systems-by-michael.html
In August of 2012 I quit my corporate job with Visa and struck out on my own again. With a handful of ideas in my bag and a tone of talent supporting me I restarted under the name Lexicom IS Redux. Below are the prototypes and services that I developed under that working name. Unable to attract investment I ran out of money and closed up the company in December of 2013. At least one of these still lives on under a different name and under very capable hands. I won't mention them by name because I have nothing to do with the huge success that team is now on the verge of enjoying - but I was there when the seeds were planted and for me that's inspiring!
I am also still prototyping Helpiado but mostly as an exercise in learning Ruby-on-Rails. I will add links and other interesting artifacts from this experience.
Software development outsourcing: http://www.hitechito.com/
(used them since 2003).
Services Prototypes + Developed:
- Prototypes
- Inspired travel apps
- Hostel management
- Gamification of travel (Badger)
- fitParade (social fashion app)
- Helpiado (mobile philanthropy app)
- Helpiado Cordova Mobile App on Github (add files)
- Developed
- Mobile Video Platform
- Enabled live video streaming via Wowza, AWS and BitGravity.
- Adaptive bitrate streaming
- Billing platform allowing members to charge for broadcasts
- Single page JavaScript application
- Spring/Hibernate backend
Early brainstorming with potential collaborators (2011):
fitParade Mechanical Turk Analysis (Basic Model) - Testing to see how many users we need to start getting collaborative filtering matches.
Helpiado logo design:
(latin) Addo - to give, bring place, inspire, cause, ad, join
fitParade Mobile App Sketches:
Subscribe to:
Posts (Atom)
