mikeash.com: just this guy, you know?

"A failure in the hot air department"
RSS feed (full text feed) - Show Tag Cloud
Showing entries tagged "hack". Full blog index.

by Mike AshTags: fridayqna xcode hack
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.

by Mike AshTags: fridayqna objectivec arc hack
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.

by Mike AshTags: fridayqna objectivec arc hack
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.

by Mike AshTags: apple xcode hack
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.

by Mike AshTags: objectivec code hack arc sourcecode
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.

by Mike AshTags: fridayqna memory hack code
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.

by Mike AshTags: fridayqna memory hack code
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.

by Mike AshTags: fridayqna blocks objectivec evil hack
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.

by Mike AshTags: fridayqna blocks objectivec evil hack
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.

by Mike AshTags: link hack trampoline
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.

by Mike AshTags: fridayqna corefoundation hack evil
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.

by Mike AshTags: objectivec code hack sourcecode
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.

by Mike AshTags: fridayqna objectivec garbagecollection hack
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.

by Mike AshTags: cocoa python pyobjc objectivec hack
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.

by Mike AshTags: fridayqna codeinjection hack evil
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
by Mike AshTags: magic c c++ hack
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
by Mike AshTags: nscell nib hack
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.
Hosted at DigitalOcean.