Cocoa with Love

cocoawithlove.com · Personal blog · on HN since 2008

Matt Gallagher writes about Cocoa, Swift and Objective-C programming on Apple platforms, including compilers, type checking and concurrency.

What HN saysHN commenters list it among good iOS and Cocoa blogs and link its post on Swift type checker problems with overloaded expressions.
69HN people shared it
27linked it in comments
136stories submitted
1.1Kstory points
3 months agolast shared
2008people per year2026

Most-shared posts

  1. 1
    Homepage
    7 people · first shared 2011
  2. 2
    Exponential time complexity in the Swift type checker
    5 people · 133 points · first shared 2016 · 46 comments on HN
  3. 3
    Comparing Swift to C++ for parsing
    4 people · 18 points · first shared 2016 · discussion on HN
  4. 4
    Compiling a Mac OS 8 Application on MacOS Sierra
    3 people · 148 points · first shared 2017 · 44 comments on HN
  5. 5
    Minimalist Cocoa programming (2010)
    3 people · 69 points · first shared 2010 · 5 comments on HN
  6. 6
    Avoiding partial functions in Swift
    3 people · 8 points · first shared 2016 · discussion on HN
  7. 7
    Mutexes and closure capture in Swift
    3 people · 7 points · first shared 2016 · discussion on HN
  8. 8
  9. 9
  10. 10
  11. 11
    Method names in Objective-C
    2 people · 13 points · first shared 2009 · 5 comments on HN
  12. 12
    Thoughts on Objective-C and how it might/should evolve
    2 people · 11 points · first shared 2010 · 3 comments on HN
  13. 13
  14. 14
  15. 15
    An aside about flatMap and monads
    2 people · 5 points · first shared 2017 · discussion on HN

What HN people wrote when they linked it

barnaclejive · 2016-04-05
More Favorites: - iOS Cookies (http://www.ioscookies.com/) - iOS Goodies (http://ios-goodies.com/) - NSHipster (http://nshipster.com/) - Cocoa With Love (http://www.cocoawithlove.com/)
msbarnett · 2011-10-17
Awesome, I wasn't aware of that one. Other good ones I know of are the already mentioned Cocoa with Love http://cocoawithlove.com/ Cocoa is my girlfriend http://www.cimgf.com/ and bbum's weblog-o-matic http://www.friday.com/bbum/
murderfs · 2026-08-14
Most expressions with overloads are a disaster in swift: https://www.cocoawithlove.com/blog/2016/07/12/type-checker-issues.html
pj4533 · 2026-01-01
Was shocked and saddened to read this blog post: https://www.cocoawithlove.com/blog/llms-twelve-months-later.html So I used Claude Code to create it, then had Claude Code examine the sessions logs in .claude/projects and generate this web page.
drivebycomm · 2025-09-05
Actually, even very basic code can cause it. The type system of Swift has issues. https://www.cocoawithlove.com/blog/2016/07/12/type-checker-issues.html let a: Double = -(1 + 2) + -(3 + 4) + -(5) Still fails on a very recent version of Swift, Swift 6.1.2, if my test works. Chris Lattner mentions something about him being more of an engineer than a mathematician, but a responsible and competent computer science engineer that is designing programming languages with complex type systems, absolutely has to at least be proficient in university-level mathematics and relevant theory, or delegate out and get computer scientists to find and triple-check any relevant aspects of the budding programing language.
jonathanyc · 2024-09-17
I only want one feature from Swift: faster type-checking. If you write a few lines of math, or a moderately complex SwiftUI expression, suddenly the typechecker starts timing out. Swift is the only language I've ever used with this problem. https://hachyderm.io/@evanw/109859384302551859 https://www.cocoawithlove.com/blog/2016/07/12/type-checker-issues.html https://danielchasehooper.com/posts/why-swift-is-slow/ This isn't mentioned at all in the announcement so I'm kind of disappointed.
macinjosh · 2022-03-21
When I learned Objective-C I remember being flabbergasted at all the method and argument names that were exceedingly wordy. At some point I read a blog post[0] that said while this is out of the ordinary when it comes to most code having long, descriptive names helps when reading code. Some people complain that it involves too much typing or takes up too much space. In reality, we spend much more time reading code than we do writing it, so names that provide context, direction, and fore-shadowing are really useful. I still tend to write method names and important variable names like that to this day in pretty much any language I use. IMHO, its a great hack. An extreme example is in the NSBitmapImageRep class [1] [0]: https://www.cocoawithlove.com/2009/06/method-names-in-objective-c.html [1]: https://developer.apple.com/documentation/appkit/nsbitmapimagerep/1395…
fulldecent2 · 2020-02-08
Here is my list of solo developer blogs. Usually they are on topic. This does not include personal blogs I follow that happen to be developers. @mdo (Bootstrop) - http://markdotto.com/ Keith Cirkel - https://www.keithcirkel.co.uk/ Coding – Corbin's Treehouse - https://www.corbinstreehouse.com/blog Aaditya Purani – Ethical Hacker - https://aadityapurani.com/ Ben Balter - http://ben.balter.com/ fulldecent - https://privacylog.blogspot.com Orange - http://blog.orange.tw/ Cocoa with Love - http://www.cocoawithlove.com/ Mark Otto - http://markdotto.com/ Moxie Marlinspike's Blog - http://www.thoughtcrime.org/blog/ hueniverse - http://hueniverse.com/
babesh · 2019-11-06
I was wrong about some of them being drawing frame related. See https://www.cocoawithlove.com/2008/12/drawing-custom-window-on-mac-os-… Apparently customizing the window frame. The CA prefixed ones are correct. Apparently, at least on a Mac, it was more about battery than performance (at least for what Mozilla did) but it was still about the amount of work they were doing per frame (for Mozilla).
bsaul · 2018-01-25
Creating a closure and scheduling it on a queue seems like a pretty heavyweight way to ensure exclusive access (see https://www.cocoawithlove.com/blog/2016/06/02/threads-and-mutexes.html… for more). EDIT: aren't you the one that wrote this article ? :))
ElectronCharge · 2017-02-21
"We have the choice of C++14, Rust and Go for well supported robust languages with different focuses." Don't forget Swift. I think it outshines all of the above (and there is active discussion of adopting ownership concepts similar to Rust's). Swift is already highly optimized. I found this article to be very interesting: https://www.cocoawithlove.com/blog/2016/05/19/random-numbers.html TL;DR: 'Both the C and Swift are now the same. I don’t just mean “they take the same time”, I mean they are compiled to literally the same instructions.' Initially the Swift Mersenne Twister code was faster, but he was able to apply an optimization to the C code that made it identical.
nglevin · 2013-02-11
Would you care to elaborate, rather than be glib? QuartzGL runs all Core Graphics on the GPU[1]. It's only available on OS X. If you can show me evidence that some API on iOS runs Core Graphics on the GPU, I'd be happy to know. I do a fair amount of work running Core Animation, CG and OpenGL at the same time, so it would be a big help. [1] - http://www.cocoawithlove.com/2011/03/mac-quartzgl-2d-drawing-on-graphi…
falava · 2013-01-09
Here is a list of some: http://speirs.org http://mattgemmell.com http://www.mikeash.com/pyblog/ http://nshipster.com http://www.objectivesee.com http://www.fruitstandsoftware.com/blog/ http://ashfurrow.com/blog/ http://www.cimgf.com/ http://www.cocoawithlove.com/ All of them extracted from here: http://ashfurrow.com/blog/blog-resources And some more: http://objectivesea.tumblr.com/ http://soff.es/ And finally, this is not a blog, but a series of videos, and not all the videos are free ($9/month subscription), but I think it's a great resource: http://nsscreencast.com/ Edit: added some urls
bosky101 · 2012-09-22
found the disclaimer & the link to the official message from echo, when reading http://cocoawithlove.com/2008/12/ordereddictionary-subclassing-cocoa.h… does disqus plan to import all those comments ?
kgutteridge · 2011-04-08
No Particular order but these blogs are worth following http://www.raywenderlich.com/ http://www.cocoanetics.com/ http://maniacdev.com/ http://furbo.org/ http://iphonedevelopment.blogspot.com/ http://idevblogaday.com/ http://cocoawithlove.com/ http://idevrecipes.com/ Im sure I have missed loads of really good ones, so looking forward to discovering some more via this ask!
jarin · 2011-02-16
Oh yeah I agree that Three20 is a cluttered, monolithic mess. What I should have said was that Three20 was the first major attempt (that I know of) to break away from the strict nested-controller way of making data-driven apps by implementing a pretty nice URL-based application model. Matt Gallagher has also done a good job of deconstructing the Apple Way and try new approaches: http://cocoawithlove.com/2009/03/recreating-uitableviewcontroller-to.h…
larrik · 2011-02-16
It's not slightly more flexible, it's hugely more flexible. As someone who has apps that consist of a complicated web of tableviews, Matt Gallagher's work is amazing and helped me immensely. Although, I think this link is better: http://cocoawithlove.com/2010/12/uitableview-construction-drawing-and.…
wallflower · 2010-07-21
http://cocoawithlove.com/2010/03/streaming-mp3aac-audio-again.html My guess is Pandora has some fairly sophisticated server-side streaming that responds to ACK/FIN-type feedback from the iPhone client.
Zev · 2009-11-09
To me, that would be a problem with your code, not Objective C or anything within the Cocoa frameworks. I would personally say that if an object is retaining its parent (or parent's parent, etc), there's something wrong with your design and you should step back to reconsider things. Matt Gallagher put it much better than I can and I would recommend reading his post on it: http://cocoawithlove.com/2009/07/rules-to-avoid-retain-cycles.html
Timothee · 2009-10-09
Regarding the category #4, this is a good tutorial on how to customize list views: http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html The kind of things that show that you went the extra mile to add polish to your app.
zackmorris · 2014-06-05
Haha I just had to post this. When I went to read about core dumps in iOS: http://stackoverflow.com/questions/7353024/when-an-app-crashes-in-ios-… I got a StackOverflow core dump, of sorts, similar to this: http://img215.imageshack.us/img215/2886/picturezb.png Currently I am using an uncaught exception handler based on this: http://www.cocoawithlove.com/2010/05/handling-unhandled-exceptions-and… But unfortunately it doesn't give very descriptive stack traces, even with debugger symbols turned on in the project settings. I'm really looking for something that shows me a full view of the program's state just like if I was in the debugger. It may be possible to extrapolate from the core dump, but I’m having a hard time figuring it out. This post summarizes how to do it with gdb: http://stackoverflow.com/questions/5115613/core-dump-file-analysis/511… But I’m thinking a huge opportunity has been lost here. This should be built into IDEs and especially for mobile apps, there should be a standard way of sending core dumps back to the developer when apps crash, especially for ad hoc builds during testing.
hackrocket · 2012-05-22
Here are some great resources for learning iOS: [1] Online courses: http://www.hackrocket.com http://teamtreehouse.com/ http://www.lynda.com/iOS-tutorials/iOS-SDK-Essential-Training/92179-2C… http://itunes.apple.com/itunes-u/ipad-iphone-application-development/i… http://codelesson.com/courses/tag/Mobile [2] Blogs/tutorials: http://developer.apple.com/library/ios/#referencelibrary/GettingStarte… http://www.raywenderlich.com/ http://cocoawithlove.com/ http://mattgemmell.com/ http://mobile.tutsplus.com [3] Books: Objective-C Programming: The Big Nerd Ranch Guide iPhone Programming : The Big Nerd Ranch Guide Cocoa Design Patterns iPhone App Development : The Missing Manual The iOS Developer's Cookbook Cocoa Design Patterns Beginning iPhone Development: Exploring the iPhone SDK [4] Forums/Q&A http://stackoverflow.com http://www.iphonedevsdk.com/forum/ [5] Videos http://www.youtube.com/user/MilmersXcode?ob=0&feature=results_main [6] Email newsletters http://tinyletter.com/hackrocket http://iosdevweekly.com/ http://iosdesign.co/
krackers · 2026-04-17
Neat, good to know! And it does seem my mental model of event loop was broken. Accessibility related interactions don't have any related NSEvent. They are handled as part of the "conceptual" run loop, but they seem to be dispatched internally by AXRuntime library from a callback off some mach port. And because of this, the call to nextEventMatchingEventMask in the main -[NSApplication run] loop never even sees any such NSEvent. -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] (in AppKit) _DPSNextEvent (in AppKit) _BlockUntilNextEventMatchingListInModeWithFilter (in HIToolbox) ReceiveNextEventCommon (in HIToolbox) RunCurrentEventLoopInMode (in HIToolbox) CFRunLoopRunSpecific (in CoreFoundation) __CFRunLoopRun (in CoreFoundation) __CFRunLoopDoSource1 (in CoreFoundation) __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ (in CoreFoundation) mshMIGPerform (in HIServices) _XPerformAction (in HIServices) _AXXMIGPerformAction (in HIServices) In some sense this is sort of similar to apple events, which are also "hidden" from the caller of nextEventMatchingEventMask. From what I can see those are handled by DPSNextEvent, which sorts based on the raw carbon EventRef. aevt types have `AEProcessAppleEvent` called on them, then the…
comex · 2018-06-08
"Does need extra work in some cases" is an understatement. With type 'inference' that's unidirectional, like in C and C++, you only need to look at each expression once. Thus, in most cases, the whole job is O(n) in the number of expressions. Admittedly, there are exceptions. For example, it's possible in C++ to create humongous types: auto p1 = std::make_pair(0, 0); // pair<int, int> auto p2 = std::make_pair(p1, p1); // pair<pair<int, int>, pair<int, int>> auto p3 = std::make_pair(p2, p2); // pair<pair<pair<int, int>, pair<int, int>>, pair<pair<int, int>, pair<int, int>>> auto p4 = std::make_pair(p3, p3); // ... Also, since templates are Turing complete, it's possible to create situations where type checking a single expression takes arbitrarily long. But neither of those are situations you're likely to run into by accident. In most real C++ programs, all the types in the program are reasonably simple, and the template system isn't used to do anything especially clever, so the O(n) bound should hold. On the other hand, full type inference, at least in a language like Swift that allows arbitrary overloads, is inherently a process of exhaustive search over an exponential number of possibilities. Now, as described in this post[1], it ought to be possible in most cases to reduce that exhaustive search to something much simpler – and I actually agree that the Swift compiler could be much, much better at doing so (although it has improved over time). …

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close