background preloader

NSHIPSTER

Facebook Twitter

Network Link Conditioner. Product design is about empathy.

Network Link Conditioner

Knowing what a user wants, what they like, what they dislike, what causes them frustration, and learning to understand and embody those motivations in design decisions—this is what it takes to make something insanely great. And so we invest in reaching beyond our own operational model of the world. We tailor our experience for different locales. We consider the usability implications of screen readers or other assistive technologiess. We continuously evaluate our implementation against these expectations. There is, though, one critical factor that app developers often miss the first time around, and that is network condition, or more specifically the latency and bandwidth of an Internet connection. This week on NSHipster, we’ll be talking about the Network Link Conditioner, a utility that allows Mac and iOS devices to accurately and consistently simulate adverse networking environments.

Installation EDGE3GDSLWiFiHigh Latency DNSVery Bad Network100% Loss. C Storage Classes. It's time, once again, to take a few steps back from the world of Objective-C, and look at some underlying C language features.

C Storage Classes

Hold onto your fedoras, ladies & gents, as we dive into C storage classes in this week's edition of NSHipster. In C, the scope and lifetime of a variable or function within a program is determined by its storage class. Each variable has a lifetime, or the context in which they store their value. Functions, along with variables, also exist within a particular scope, or visibility, which dictates which parts of a program know about and can access them.

There are 4 storage classes in C: auto register static extern At least a few of these will look familiar to anyone who has done a cursory amount of Objective-C programming. Auto There's a good chance you've never seen this keyword in the wild. Automatic variables have memory automatically allocated when a program enters a block, and released when the program leaves that block. Register static Static Singletons. AVSpeechSynthesizer. Though we're a long way off from Hal or Her, we should never forget about the billions of other people out there for us to talk to.

AVSpeechSynthesizer

Of the thousands of languages in existence, an individual is fortunate to gain a command of just two within their lifetime. And yet, over several millennia of human co-existence, civilization has managed to make things work, more or less, through an ad-hoc network of interpreters, translators, scholars, and children raised in the mixed linguistic traditions of their parents. We've seen that mutual understanding fosters peace, and that conversely, mutual unintelligibility destabilizes human relations. It is fitting that the development of computational linguistics should coincide with the emergence of the international community we have today. Another related linguistic development is the Esperanto language, created by L. Introduced in iOS 7, AVSpeechSynthesizer produces synthesized speech from a given AVSpeechUtterance. NSString *string = @"Hello, World! " KVC Collection Operators.

Rubyists laugh at Objective-C's bloated syntax.

KVC Collection Operators

Although we lost a few pounds over the summer with our sleek new object literals, those Red-headed bullies still taunt us with their map one-liners and their fancy Symbol#to_proc. Really, a lot of how elegant (or clever) a language is comes down to how well it avoids loops. for, while; even fast enumeration expressions are a drag. No matter how you sugar-coat them, loops will be a block of code that does something that is much simpler to describe in natural language. "get me the average salary of all of the employees in this array", versus... double totalSalary = 0.0;for (Employee *employee in employees) { totalSalary += [employee.salary doubleValue];}double averageSalary = totalSalary / [employees count]; Meh. Fortunately, Key-Value Coding gives us a much more concise--almost Ruby-like--way to do this: [employees valueForKeyPath:@"@avg.salary"];

Key-Value Observing. Ask anyone who's been around the NSBlock a few times: Key-Value Observing has the worst API in all of Cocoa.

Key-Value Observing

It's awkward, verbose, and confusing. And worst of all, its terrible API belies one of the most compelling features of the framework. When dealing with complicated, stateful systems, dutiful book-keeping is essential for maintaining sanity. Lest the left hand not know what the right hand doeth, objects need some way to publish and subscribe to state changes over time. In Objective-C and Cocoa, there are a number of ways that these events are communicated, each with varying degrees of formality and coupling: **NSNotification** & **NSNotificationCenter** provide a centralized hub through which any part of an application may notify and be notified of changes from any other part of the application.

Of all of these methods, Key-Value Observing is arguably the least well-understood. Subscribing The method used to add an observer is –addObserver:forKeyPath:options:context:: Yuck. Responding.