NSBlog
"A failure in the hot air department"
Showing entries tagged "hack". Full blog index.
Friday Q&A 2015-08-14: An Xcode Plugin for Unsmoothed Text
at 2015-08-14 14:11
Getting Xcode to display unsmoothed text in its editor has been an ongoing battle which finally required me to write an Xcode plugin to impose my will. Several readers asked me to discuss how it works, which is what I'm going to do today.
Friday Q&A 2012-06-01: A Tour of PLWeakCompatibility: Part II
at 2012-06-01 13:38
Last time, I discussed the basics of PLWeakCompatibility in terms of the motivation, the basic hooks used to get the compiler to call our code when handling
__weak
variables, and calling through to the original implementations where available. Today, I'm going to discuss the implementation of the zeroing weak reference facility that gets used when the runtime doesn't supply its own __weak
support.Friday Q&A 2012-05-18: A Tour of PLWeakCompatibility: Part I
at 2012-05-18 16:53
A few weeks ago, I introduced
PLWeakCompatibility
. This is a small library that can be dropped into an app to enable use of the __weak
qualifier on OSes that don't support it. ARC is officially supported on Mac OS X 10.6 and iOS 4, but __weak
is only available on 10.7 and iOS 5. PLWeakCompatibility
adds support for __weak
on those older OSes when using ARC. Today I'm going to discuss how PLWeakCompatibility
works on the inside.Solving Simulator Bootstrap Errors
at 2012-05-07 20:06
I'm sure every iOS developer has seen the dreaded bootstrap error. "Couldn't register com.yourcompany.yourapp with the bootstrap server. Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger." After nearly throwing my Mac out the window for the Nth time today, I finally managed to come up with a simple fix. Run this in the shell:
launchctl list|grep UIKitApplication|awk '{print $3}'|xargs launchctl remove
. And your bootstrap errors magically melt away.Introducing PLWeakCompatibility
at 2012-03-31 03:09
As a way of atoning for the lack of a Friday Q&A today, I'm pleased to introduce PLWeakCompatibility. Do you like ARC? Do you need to support older OS releases? Do you wish you could use
__weak
variables on those older OSes? If so, then I have good news for you! PLWeakCompatibility is the solution you've been looking for.Friday Q&A 2012-02-17: Ring Buffers and Mirrored Memory: Part II
at 2012-02-17 12:50
Last time on Friday Q&A, I started talking about implementing a ring buffer using virtual memory tricks to mirror memory. The first article concentrated on those virtual memory tricks. Today, I'm going to fill out the second half of the puzzle and show how to implement the ring buffer on top of the mirrored memory allocator we developed. If you haven't read the previous article yet, I strongly recommend you so so, otherwise the memory mirroring is likely to be confusing.
Friday Q&A 2012-02-03: Ring Buffers and Mirrored Memory: Part I
at 2012-02-03 16:37
Playing with virtual memory is always fun, and one place where it can be put to good use is in building a ring buffer. A ring buffer is a way to implement a FIFO queue of data, and using virtual memory tricks to mirror multiple copies of the same data can make the implementation simpler and better by virtually concatenating noncontiguous data. Readers Jose Vazquez and Dylan Lukes suggested that I explore the building of such a construct. Today I will talk about how to implement the virtual memory tricks, and then in part II I will show how to implement the ring buffer on top of them.
Friday Q&A 2011-11-11: Building a Memoizing Block Proxy
at 2011-11-11 16:06
Last time, I talked about my crazy hack that misuses the Objective-C message forwarding machinery to do block proxying. This allows writing code that interposes in front of an arbitrary block to intercept its arguments, manipulate its return value, etc. Today, I want to present an exanmple of using this hack which almost verges on the practical. Specifically, I'm going to discuss how to use it to build a generalized block memoization facility.
Friday Q&A 2011-10-28: Generic Block Proxying
at 2011-10-28 13:57
Here at Friday Q&A, I pride myself on occasionally taking my readers to places where normal people dare not tread. Today is one of those days. This is not a reader suggested topic, but today I want to talk about a fun hack I came up with that allows proxying block invocations in much the way that one can proxy Objective-C messages.
Link: Implementing imp_implementationWithBlock
at 2011-04-14 16:26
Friend of the blog Landon Fuller has created a third-party implementation of Apple's new
imp_implementationWithBlock
API, and has also written a blog post on how it all works.Friday Q&A 2010-07-30: Zeroing Weak References to CoreFoundation Objects
at 2010-07-30 19:01
It's time for another friendly edition of Friday Q&A. For my last Friday Q&A, I talked about
MAZeroingWeakRef
and how it's implemented for pure Objective-C objects. For this one, I'm going to discuss the crazy hacks I implemented to make it work with toll-free bridged CoreFoundation objects as well.Introducing MAZeroingWeakRef
at 2010-07-16 20:19
I'm extremely excited to announce a new library for Cocoa and Cocoa Touch development:
MAZeroingWeakRef
. In short, it's a library which allows zeroing weak references to be used in retain/release Cocoa code. This has all sorts of uses and should make retain/release coding less painful. While I discussed this in detail in my Friday Q&A post this week, I also want to make a separate announcement for people who don't want to read through all of the horrible details.Friday Q&A 2010-07-16: Zeroing Weak References in Objective-C
at 2010-07-16 20:18
It's that time of the biweek again. For this week's Friday Q&A, Mike Shields has suggested that I talk about weak references in Objective-C, and specifically zeroing weak references. I've gone a bit further and actually implemented a class that provides zeroing weak references in Objective-C using manual memory management.
Friday Q&A 2009-11-20: Probing Cocoa With PyObjC
at 2009-11-21 02:44
It's another Friday and time for another Friday Q&A. This week, fellow Amoeba Jeff Johnson suggested talking about using Cocoa from the command line using Python and PyObjC.
Friday Q&A 2009-01-30: Code Injection
at 2009-01-30 18:34
Welcome back to another exciting Friday Q&A.; This week I'll be taking Jonathan Mitchell's suggestion to talk about code injection, the various ways to do it, why you'd want to, and why you wouldn't want to.
Hacking C++ From C at 2006-08-03 00:00
For a long time, LiveDictionary used deeply unwholesome methods to do its work. Version 1.2.5, just released, now uses nothing but public methods. This means vastly improved stability, but it also means that LiveDictionary's evil WebKit text grabber, once considered the app's crown jewels, is no longer useful. I'm going to use it as an object lesson on how to do evil things with C++ applications from pure C.
Custom NSCells Done Right at 2006-04-06 00:00
Anyone who's done enough Cocoa has eventually run into the nightmare that is subclassing an NSCell. While it looks simple enough, actually getting an Interface Builder-generated control to use your NSCell subclass is effectively impossible. You either have to use CustomViews in IB, write an IBPalette, or do a whole lot of tedious and error-prone manual copying of attributes to get everything from the IB-provided cell into your own.