赞
踩
http://www.mikeash.com/pyblog/
struct
s containing only a single field.
NSString
's
stringWithFormat:
method.
NSWindowController
subclass. I'll walk through what this means and how to do it, a topic suggested by reader Mike Shields.
NSInvocation
as
MAInvocation
. In that article, I discussed the basic theory, the architecture calling conventions, and presented the assembly language glue code needed for the implementation. Today, I present the Objective-C part of
MAInvocation
.
NSInvocation
, and I have obliged, implementing it from scratch for your amusement. Today I'll start on a guided tour down the hall of horrors that is
MAInvocation
, my reimplementation of the
NSInvocation
API. It's a big project, so today I'm going to focus on the basic principles and the assembly language glue code, with the rest of the implementation to follow.
UITableView
.
NSObject
. I left out key-value coding, because the implementation of
valueForKey:
and
setValue:forKey:
is complex enough to need its own article. This is that article.
NSObject
class lies at the root of (almost) all classes we build and use as part of Cocoa programming. What does it actually do, though, and how does it do it? Today, I'm going to rebuild
NSObject
from scratch, as suggested by friend of the blog and occasional guest author Gwynne Raskind.
dyld
does its job. This week, I'm going to recreate the function of both the compiler and the
static linker, building a Mach-O binary completely from scratch with only the help of the assembler.
objc_msgSend
function underlies everything we do in Objective-C. Gwynne Raskind, reader and occasional Friday Q&A guest contributor, suggested that I talk about how
objc_msgSend
works on the inside. What better way to understand how something works than to build it from scratch? Let's build
objc_msgSend
.
dyld
, the OS X dynamic linker. I found this particular corner of the system interesting, and I see a lot of people having trouble with linking issues, so I decided to do an article about the basics of dynamic linking. Some of the deeper logic is new to me, so sorry in advance for any inaccuracies.
NSBitmapImageRep
.
NSImage
lets you treat an image as an opaque blob that you can just draw where you want it. Core Image wraps a lot of image processing in an easy-to-use API that frees you from worrying about how individual pixels are represented. However, sometimes you really just want to get at the raw pixel data in code. Scott Luther suggested today's topic: fetching and manipulating that raw pixel data.
goto
, so be warned!
NSNumber
class. Starting on Mac OS X 10.7 and iOS 5,
NSNumber
uses a new runtime facility called tagged pointers to increase speed and reduce memory usage, the inner workings of which I want to examine today.
NSNumber
is a deceptively simple class with some interesting implementation details. In today's edition of Friday Q&A, I'll explore how to build a class that works like
NSNumber
, a topic suggested by Jay Tamboli.
__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.
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.
launchctl list|grep UIKitApplication|awk '{print $3}'|xargs launchctl remove
. And your bootstrap errors magically melt away.
__weak
variables on those older OSes? If so, then I have good news for you! PLWeakCompatibility is the solution you've been looking for.
NSMutableArray
. Today, I'll repeat the same exercise with
NSMutableDictionary
and build an implementation of it from scratch.
NSMutableArray
works behind the scenes by building a replacement for it from scratch.
MAKVONotificationCenter
. It's been a long time since then, and it was high time such a useful piece of code got an update, which I gave it. With the help of Mike and
Tony Xiao, it's gotten a full overhaul and is now a modern code library with some fun features. In this article, I'm going to go through the new stuff and how it was done.
x86_64
assembly.
NSAutoreleasePool
and how it works internally. Today, I'm going to carry that theme forward by building an implementation of Cocoa reference counting with
retain
and
release
, a topic suggested by David Dunham.
NSAutoreleasePool
works behind the scenes. I decided that the best way to do that would be to simply reimplement it, and that is what I'll discuss today.
warning: no '-fooMessage' method found (Messages without a matching method signature will be assumed to return 'id' and accept '...' as arguments.)
You double-check your code and your method name is correct, so you shrug and move on. A few hours later, your program starts misbehaving strangely. What's going on? Today, I'll explore the mysterious world of Objective-C method signature mismatches, a topic suggested by an anonymous reader.
NSNotificationCenter
workalike from scratch to illustrate how it all works, a topic suggested by Dylan Copeland.
lldb
, the new debugger from the LLVM project, is quickly gaining functionality, the gold standard for debugging Cocoa apps is still
gdb
. Today I'm going to discuss how to use
gdb
and various tips and tricks for getting the most out of it, a topic suggested by Luis de la Rosa.
NSZombie
works, and that's the topic I will discuss today.
imp_implementationWithBlock
API, and has also written
a blog post on how it all works.
0x7DB
, I decided to write about practical floating point, a topic suggested by Phil Holland.
cocoa-dev
has borne fruit! Brent Simmons has graciously created
cocoa-unbound
, a group dedicated to Cocoa discussion but without the foolishness. I've already joined, and I encourage you to do so as well. A well-trafficked mailing list where we can talk about Mac programming without minions of the Mothership getting in our way will be a wonderful resource to have.
NSCoding
in Objective-C classes.
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.
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.
NSPointerArray
,
NSHashTable
, and
NSMapTable
, a topic suggested by Phil Holland.
NSError **
call into CPS style with virtually no work. Source code and extensive examples are available, and I encourage you to
check it out.
NSNotificationQueue
, a little-known, poorly-understood, but handy Foundation class.
NSRunLoop
internals.
@executable_path
, and friends.
printf
-style format strings in C, as suggested by Kevin Avila.
const
and
restrict
.
Last week I discussed the basics of
volatile
and why it's not very useful. This week I'm going to finish up by discussing the use of
volatile
in a multithreaded context.
const
and
restrict
qualifiers. This week I will continue with a discussion of the third qualifier,
volatile
.
top
) in Mac OS X.
@dynamic
properties work in CoreData and I'm going to take that and expand it to talk about message forwarding in general.
strnstr
. This bug was fixed in Leopard, but persisted in Tiger. Today, Apple
finally fixed it in Tiger. Now you can safely use
strnstr
. I assume that this bug probably still exists on Panther and earlier, but as long as you're targeting Tiger and up (as every sane person ought to), you are now safe.
rtfd
files which are under version control, and it's painful. TextEdit and Xcode will blow away the version control directory (if you use the sort of version control which keeps directories in everything) and it's annoying to work around it. I finally got fed up enough to write a script which works around it for me.
strnstr
function is broken on Mac OS X 10.4 (and presumably earlier) and should be avoided.
AtomicReplaceDirectory
. The very first line of this function was a comment that said:
note, despite the name, this is *not* atomic.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。