Starting to write unit tests in Swift 2 / Xcode 7 so thought I would keep a list of resources and share. Plan to keep this post updated as I find more. Feel free to ping additional resources in the comments!
I’m working on an iOS app written entirely in Swift that uses the Google Analytics library. At Google I/O 2015 they announced full support for Swift and even CocoaPods (which doesn’t actually work if any of your other libraries use_frameworks! – but they are working on that and it’s not a trivial fix). The initial intro documentation from Google has options to show the code sample in either Objective-C or Swift, but all the rest of the documentation still seems to be Objective-C, only. I was listening to the More Than Just Code podcast tonight and Aaron Vegh was remarking on how going back to Swift code just wasn’t clicking, and he found it easier to just write stuff in Objective-C. So I thought, hey, until Google updates their docs, why not list some Swift code samples for how to implement various things in Swift.
Here I just want to look at a simple task: Event tracking in Google Analytics. Yes, this might seem trivial, but when you’re a developer switching back and forth between Objective-C and Swift, sometimes it’s nice if someone points out the syntax, as per Aaron’s comments.
Here’s the Objective-C code (adapted from the Google Docs, link above):
[tracker send:[[GAIDictionaryBuilder createEventWithCategory:@"ui action"
And here’s the Swift equivalent:
tracker.send(GAIDictionaryBuilder.createEventWithCategory("ui action", action: "button press", label: "do something", value: 1988).build() as [NSObject : AnyObject])
btw if anyone comes up with, or knows of, a nice plugin for WordPress to color code Swift appropriately, please let me know! 😛
As an iOS / Swift mentor for Thinkful.com, every week I give my students a list of resources as a follow up to our mentoring session. This week’s resources cover details of dealing with data loaded from the Internet, storing data locally (core data and alternatives to core data), and cloud services. Finally we wrap up with some photoshop tips to automatically create 1X, 2X, and 3X assets for your iOS projects.
This week’s resources relate to putting together your UI in Interface Builder – Auto Layout, Adaptive Layout, Size Classes, Dynamic Text, and mastering the Interface Builder IDE. Additionally, we touched on architectural design patterns (MVC, MVVM, etc.). Finally, most of my students are starting to struggle with networking via the AFNetworking library, and using Objective-C libraries (although none of them know any Objective-C) in their Swift apps using bridge headers. Continue reading “this week’s iOS related resources”
so microsoft’s strategy has been, ‘one OS for ALL devices’
Apple’s strategy is, ‘one, seamless, continuous experience across ALL devices’.
It might sound like a subtle difference at first glance, but it’s a universe of a difference. Microsoft demands the user make the same OS work no matter what device you’re on, so we find folks griping about a touch interface on a non-touchscreen device etc.
The Apple user might start writing an email on his/her iPhone, then sit down at a computer and finish it there – the half composed email is magically there. The UX fits the device, and there is continuity of the task itself.
Apple asked the question, ‘what if we could have Objective-C, without the baggage of C’. The answer is a new language: Swift
My ten year son is quickly catching up to me in terms of comfort with command line / terminal. He’s going through Learn to Program with Minecraft Plugins, which I heard about through our local Coder Dojo. It’s an intro to programming in Java with Minecraft as the interest / lure. I was surprised to find that he took a command-line approach in the book, but even more surprised to find how readily my kid picked up on it. I highly recommend picking up the e-book if you want to learn programming yourself or want your kids to learn. Prior to this we picked up Scratch, which we also got introduced to through Coder Dojo, but I found that the kids quickly devolved into just playing games or spending hours drawing instead of actually learning to code anything.
For my six year old, though, I found Kodable for free on the iTunes store. I found it while searching for something that was (a) based on Logo and (b) would work on the iPad. Kodable is extremely well done – it teaches concepts like iteration and conditional logic through a series of puzzle games with cute graphics and sound effects. My daughter doesn’t feel like she’s learning, she feels like she’s playing a game and letting her play is a “reward” rather than an exercise. After her first session, she told her mom “I’m contracting for baba (daddy)”!
Some time ago I read this post, “I will not do your tech interview“. It’s an awesome commentary and I agree with it wholeheartedly. As a consultant, I have to do a lot of interviews, and many times it’s hard to know a lot about the company who is going to interview me, or their corporate culture, or what to expect, ahead of time. Hence, for me interviews are a two-way street – I am as much interviewing my potential client, as they are interviewing me. Today I had a particularly hilarious interview. The interviewers started off the interview by telling me their names and then proceeding to read from a grocery list of academic text-book questions. That alone made me do a double take, even though I had been warned this would be a ‘technical interview’. What, you don’t want know jack about me? How are going to know if I’m pleasant to work with, or what my personality is like? If those things don’t matter to you, what kind of insane work environment do you guys have?
At the end of the interview, which was for a Flex project, I asked them, ‘so, are you guys using the latest Apache Flex build, or what version are you using?’. One of the guys proceeded to give me another grocery list – this time of all the technologies they are using, from Ruby, to MySQL. Hm. Let’s try that again. ‘WHAT VERSION OF FLEX ARE YOU ACTUALLY USING?’
He said, ‘oh we’re using the old (Adobe) one, because Apache Flex doesn’t support AIR’.
WOW. Can you spell M-O-R-O-N? Never mind, that Apache Flex has always supported AIR from day one, and that if it didn’t it would be like Microsoft not supporting Windows anymore. Any monkey who bothered to even visit the Apache Flex web site would realize that. So, what you’re telling me, is that at your company, where you’re building ‘enterprise level’ projects in Flex, nobody in your team has bothered to keep up with the current state of affairs of Flex itself, and you’ve made serious architectural decisions regarding your software based on some ridiculous assumptions? Yeah, sign me up right away…NOT.