HN user

matttthompson

1,038 karma
Posts31
Comments56
View on HN
nshipster.com 11y ago

Developing with Pay on iOS

matttthompson
15pts0
github.com 11y ago

Alamofire: HTTP Networking in Swift

matttthompson
99pts28
nshipster.com 11y ago

// MARK: is the new #pragma (…and other changes to documentation in Swift)

matttthompson
1pts0
nshipster.com 12y ago

Syntactic Icing with Swift Custom Operators

matttthompson
1pts0
nshipster.com 12y ago

Xcode Plugins

matttthompson
2pts0
mattt.me 12y ago

$1 Million

matttthompson
2pts0
nshipster.com 12y ago

Xcode Launch Arguments & Environment Variables

matttthompson
1pts0
github.com 12y ago

AFNetworking 2.0

matttthompson
135pts18
asciiwwdc.com 12y ago

ASCIIwwdc: Searchable full-text transcripts of WWDC sessions

matttthompson
37pts10
nshipster.com 12y ago

Obscure APIs in iOS 7: Smile Detection, Speech Synthesis & QR Code Scanning

matttthompson
2pts0
rocket.github.io 12y ago

Rocket: a hybrid approach to real-time cloud applications

matttthompson
4pts0
nshipster.com 13y ago

Creating DSLs in Objective-C with Object Subscripting

matttthompson
3pts0
nshipster.com 13y ago

NSHipster: NSURLCache

matttthompson
1pts0
github.com 13y ago

Rack::PushNotification: Run your own push notification service on Heroku

matttthompson
7pts0
mobile.heroku.com 13y ago

Build an iOS App on Heroku in 10 Minutes

matttthompson
132pts27
nshipster.com 13y ago

NSHipster: a journal of the overlooked bits in Objective-C and Cocoa.

matttthompson
2pts0
github.com 14y ago

AFIncrementalStore: Core Data with AFNetworking, Done Right

matttthompson
33pts11
devcenter.heroku.com 14y ago

Building Full Text Search and Pattern Matching on iOS with Postgres

matttthompson
2pts0
devcenter.heroku.com 14y ago

Network Caching on iOS using HTTP Cache Headers

matttthompson
1pts0
mesmerizeapp.com 14y ago

Mesmerize: It's like Heroku + TestFlight for Mac Developers

matttthompson
1pts0
github.com 14y ago

Show HN: Sinatra-Param — Design by Contract for Query String & Form Parameters

matttthompson
1pts0
inductionapp.com 14y ago

Induction: A Polyglot Database Client For Mac OS X

matttthompson
283pts82
github.com 14y ago

AFNetworking 0.9 released

matttthompson
1pts0
engineering.gowalla.com 14y ago

AFNetworking: A Delightful Networking Library for iOS and Mac OS X

matttthompson
59pts13
mattt.me 14y ago

"Because We're All Persons": Empathy and Open Source

matttthompson
4pts0
github.com 14y ago

IOS Developers, It's Time To Ditch ASIHTTPRequest

matttthompson
4pts4
github.com 15y ago

Gowalla's iOS networking libraries are now open-source

matttthompson
2pts0
mattt.github.com 15y ago

-- --- •-• ••• • -•-• --- -•• • •• -• •--- •- •••- •- ••• -•-• •-• •• •--• -

matttthompson
180pts40
mattt.github.com 15y ago

Using jQuery and the <ruby> tag to annotate text with Morse Code

matttthompson
5pts2
ddddribbbled.com 15y ago

DDDDRIBBBLED: the awkward love child of dribbble and FFFFOUND

matttthompson
1pts0
iOS Code Samples 11 years ago

And to be clear—these are all existing sample apps for open source Objective-C projects. The creator of this site does not appear to have done anything but gathered these up into zip files. The complete lack of attribution is misleading.

iOS Code Samples 11 years ago

I don't understand why this is getting so much attention. This is nothing more than a couple zip files containing a few Objective-C open source projects that happen to have example projects.

As far as I can tell, the only original contributions here are that the author tested the apps (in an old version of Xcode) and wrote vague descriptions of what those projects did.

As @orta mentions in another comment, http://cocoapods.org already has a canonical database of thousands of projects. And there are plenty of other sites that do a much better job of curating (and properly attributing) interesting projects.

Edit: Link to original HN submission (2012), for anyone curious - https://news.ycombinator.com/item?id=4182483

The Death of Cocoa 12 years ago

I have no illusions about the amount of effort and investment necessary to change technology stacks. Carbon was only officially deprecated in OS X 10.8. To speak of the death of technology is only to acknowledge that it is mortal.

My claim isn't that everything will be rewritten in Swift—far from it. Instead, the article is an exploration of what it would mean for Swift to evolve beyond the constraints of Objective-C & Cocoa interoperability, and how that may occur as Swift gains momentum.

The Death of Cocoa 12 years ago

I appreciate your feedback, but I think you're reading an entirely different argument than what is presented in the article. It's not that everything is going to be rewritten in Swift (I'm not sure where you got that idea). Rather, the article is an exploration of what Swift without Obj-C & Cocoa could be, and under what circumstances that might become a reality.

If Swift doesn't have to accommodate Objective-C as it currently does, it's reasonable to assume that system frameworks will be designed and built in ways that make the most of Swift's language features, just as Cocoa currently does with Objective-C.

You make some good points, and I agree to caution against names that bear no semantic relationship with their purpose. My justification of Alamofire is that it reflects the history of the project, which traces back from AFNetworking to Gowalla (formerly Alamofire, Inc.), the product for which it was originally developed.

Was there any reason why you chose callbacks over a Promise-like pattern for the async responses?

Deeply-nested networking callbacks are a code smell, and I find that promises often do more harm by hiding those smells—or worse, obscuring the flow itself. In practice, Alamofire is mostly going to be single or at most nested two levels deep anyway.

The short answer: Use the version of `request` that takes a `URLRequestConvertible`, and specify the header fields in that.

The long answer: Custom headers on a per-request basis are a bit of a red herring, from an API design perspective. In reality, most use cases boil down to one of three, which are taken care of in other ways:

- Default headers, such as `User-Agent`, are specified in `NSURLSessionConfiguration -HTTPAdditionalHeaders`. - `Authorization` headers, which are handled by `NSURLCredential` and `NSURLAuthenticationChallenge`. - `Content-Type` headers, which are handled by `ParameterEncoding`.

This is why Alamofire is designed the way it is.

Swift Operators 12 years ago

Author of the article here. Let me know if you have any questions or feedback.

...ending up in an error block because of a malformed server response is a pain in the ass. Is it really an error if you get a 200 OK response but the body isn't valid JSON?

Yes. Oh goodness, yes it is. Having consistent validation on the networking level means not having sporadic logic scattered throughout models and view controllers.

Your server sent invalid JSON (e.g. sending HTML instead)? AFNetworking just saved you from a crash, or some other undefined, dangerous behavior.

AFNetworking is pedantic because networking is such a wildcard, in terms of performance, consistency, and security.

Nothing in AFNetworking forces a success/failure block. For request operations, `completionBlock` can be set directly. For session tasks, the parameter is a `completionHandler`.

There's plenty of room for simplicity and abstraction, but this is not a particularly good one, if I'm going to be honest. I can't think of any situation in which I'd recommend this over either AFNetworking or the built-in Foundation URL Loading system.

If i want to generate url requests, i have to use a serializer class...

No, you don't. There's nothing stopping you from creating `NSURLRequest` directly.

...wouldn't it be better to just expose all the setup functionality through simple wrapper functions?

Request serializers are not unlike any other class in Cocoa, like say NSURLSessionConfiguration, which is not often mutated beyond initial setup, but exposes properties to remain flexible and not overwhelm the user with init parameters.

What you're suggesting sounds much, much worse.

For multipart requests, why did a protocol with appends and requiring a block with stateful appends end up making more sense than just taking an array of the parts?

Not using a protocol / builder pattern here would be awful.

You'd have to create classes for each kind of part, which gets complicated because AFNetworking handles data, files, and streams alike. So that's, like, 3 extra top-level classes. And even that doesn't really work, since it makes it really difficult to just append data to the multipart body manually, in case there was some missing functionality that AFN didn't provide. Add to that the consideration of how to specify options on the stream itself, like throttling...

You should give all of that another look—it's one of the best parts of AFNetworking.

I'm all about seeing new ideas about how to approach networking architectures, but this one makes me worried for anyone who decides to adopt it.

Networking is an inherently complex problem. Attempting to simplify the problem by ignoring those complexities, rather than actually deal with them, misses the point entirely.

This library in particular demonstrates an unfortunate lack of understanding of why Apple has designed its networking stack the way it has. As a result, it needlessly duplicates interfaces and functionality of built-in classes.

Not exposing NSURLRequest means that there's no support for caching policies, or HTTP pipelining, or setting an HTTP body stream, or control over cellular access. Not using NSURLCredential or exposing authentication challenges means that you lose support for digest auth, NTLM, and kerberos, and leaves the user vulnerable to Man-in-the-Middle attacks for lack of certificate pinning and verification. Not exposing other delegate methods means no backgrounding support, no cache control, and no extensibility beyond what the original author envisioned.

AFNetworking is modular and composable. If you don't want to deal with its complexity, you can ignore a lot of it. If you don't need much, just use the built in NSURLConnection or NSURLSession classes (they're actually quite nice). But seriously, don't settle for a wrapper library that dumbs down a problem; you'll regret it soon enough.

AFNetworking 2.0 13 years ago

In my opinion, no better case for AFNetworking 2.0 wrt/NSURLSession can be made than AFURLSessionManager, and all of the great stuff it does for you. http://cocoadocs.org/docsets/AFNetworking/2.0.0/Classes/AFUR...

Another essential feature is SSL pinning, which helps prevent against man-in-the-middle attacks and other vulnerabilities. If your app interacts with any sensitive customer information, you would be well-advised to take a look at AFSecurityPolicy: http://cocoadocs.org/docsets/AFNetworking/2.0.0/Classes/AFSe...

If you're using UIKit, there's a good chance that at least one of the many UIKit extensions would be worth your while: https://github.com/AFNetworking/AFNetworking/tree/master/UIK...

I also think serializers will have a dramatic impact on the reusability and composability of business logic across your application in a really elegant way.

I'd be very interested to hear your thoughts as you do networking on iOS 7 with and without AFNetworking. Feel free to reach out over Twitter or email.

AFNetworking 2.0 13 years ago

Yes, AFNetworking 2.0 (with the exception of `NSURLSession` functionality) is compatible with iOS 6 and Mac OS X 10.8.

(This was changed from the original plan to only target iOS 7, after it was determined that A) only the two classes needed iOS 7, and B) although iOS 7 adoption is crazy good, the same isn't as true of OS X)

To clarify: I mean to say that 0 represents "nothing" in C in the same way that it does in math. This is one of the things I love about C--the ability to exploit the properties of numbers directly, rather than needing to build abstractions around them. Bitmasks, for example, are one of my favorite things ever.

But yeah, point well-taken. Perhaps I'll take the opportunity to wax on the other special values used in Foundation & CoreFoundation sometime.

For clarification, this is a list of some reader-submitted tricks and tips from the last month, as a way to bring in the New Year.

I'm looking forward to doing more of these in the future, so if anyone has any ideas or suggestions, feel free to tweet them to @NSHipster. Thanks!

Heroku is the platform of choice for thousands of iOS, Android, Windows Phone, (and mobile web, of course) applications.

This screencast was merely a demonstration of what a rapid iOS development workflow with the Core Data Buildpack looks like.

> Great for simple demo apps, but very painful when you have slightly more complex needs.

Unlike Storyboards, the effort you put into writing against a REST API isn't wasted if you decide to roll a new, more complex REST API (which Heroku is fantastic for).

The whole point is to get the developer up-and-running as quickly as possible. Code for the API you'll eventually have, but get by with a rough scaffolding so you can experiment and iterate rapidly.

I have a theory that this could be accomplished in the NSPersistentStoreCoordinator by setting up sister contexts--one for network, one for SQLLite. Network is the master, and replicates to SQLite, which could be used for reads if the network is slow or down.