Draft Review: Injecting data into Obj-C readonly properties

22 views
Skip to first unread message

Lee Winder

unread,
Jul 30, 2014, 8:26:08 AM7/30/14
to altdev...@googlegroups.com
Originally posted on my blog last week, but thought I'd put it up for review before posting onto AltDev
http://www.altdev.co/?p=31230&shareadraft=baba31230_53d8e3c94aaf3

I'm actually debating whether to publish this anyway, the syntax highlighting not working (and I don't have time to create multiple Gists to inject the code) makes it look like a wall of text, which I really don't like. 

But either way, thanks in advance for any feedback.

Alex 'darbotron' Darby

unread,
Jul 31, 2014, 7:19:13 PM7/31/14
to altdev...@googlegroups.com
Hi Lee

I followed it easily enough despite not having wirtten obj-c for 18 months or so, if I'm understanding this correctly the solution manually replaces the generated property getter function in the object's 'vtable' (not sure what you call it in obj-c) subverting its behaviour to do what you need without breaking the 'readonlyness' of the property.

A very useful obj-c trick that I hope I never need to use (because syntax!!!! bleugh.)

I did have some trouble following the TL; DR part:
1) the function (message?) names don't seem to match up, and 
2) the term 'swizzle' is a very different usage to how I've heard it used before which also threw me (e.g. texture swizzling on PS2)

Generally: a great (if very specific) nugget of wisdom :)

Oh, also you have a typo - "it's" when you mean "its" here "So we’re stuck with the SKPaymentTransaction and it’s API looks something like this"

Cheers,

Alex

Lee Winder

unread,
Aug 1, 2014, 1:56:14 AM8/1/14
to altdev...@googlegroups.com
Thanks Alex, the function names was a copy/paste error, that's been fixed up now, along with the it's/its.

Cheers
Lee

Alex 'darbotron' Darby

unread,
Aug 2, 2014, 5:21:40 AM8/2/14
to altdev...@googlegroups.com
No worries dude ;)
Reply all
Reply to author
Forward
0 new messages