August 16th, 2009 · Comments Off · Default
Mike Ash posted a great article about problems with Cocoa’s Key Value Observing and provided a better set of classes to work with KVO: MAKVONotificationCenter. I’ve been using Mike’s code in various projects over the last few months and am a big fan.
When I started development on MOO I knew I wanted the project to use Mike’s code but I also wanted to take advantage of Cocoa’s Garbage Collection and Snow Leopard’s blocks. I originally tried to retrofit MAKVONotificationCenter to work with GC and with blocks but it rapidly become a very difficult task. So I wrote my own KVO Notification class that was fully GC compatible and worked purely with blocks (no delegate methods at all).
Jumping as quickly into the code as I can, here is an example showing a KVO block that modifies a CoreAnimation layer’s position in responses to changes in the application’s model (example code adapted from MOO’s CGameMapView.m):
void *theBlock = ^(NSString *keyPath, CALayer *self, NSDictionary *change, id identifier)
{
self.position = CGPointMake(self.viewPoint.scale * self.modelObject.position.x, self.viewPoint.scale * self.modelObject.position.y);
};
CALayer *theLayer = ...;
[theLayer addKVOBlock:theBlock forKeyPath:@"modelObject.position" options:0 identifier:@"KVO_IDENTIFIER_1"];
[theLayer addKVOBlock:theBlock forKeyPath:@"viewPoint.scale" options:0 identifier:@"KVO_IDENTIFIER_2"];
I find this, blocks based, style of KVO handling much cleaner and easier to both code and maintain. No worrying about selectors and targets and passing whatever data you need into the delegate method. You just declare your block and register it with the KVO Notification Center.
Clean-up (unregistration) is also straight-forward, although with Garbage Collection enabled applications this isn’t usually even necessary.
If you’re sharp-eyed you might notice that I’ve called one of the block parameters “self”. By providing my own ’self’ parameter I am obscuring and prevent access to the parent method’s ’self’ parameter. The reason I am doing this is because I’ve found it is very common to register for notifications for “self” and unless you’re very careful you can end up with a horrible retain cycle caused memory leak. By providing my own self parameter I obscure the parent method’s self and make sure these kind of retains cycles don’t happen.
The code is released under the BSD License on bitbucket (mercurial): http://bitbucket.org/schwa/kvoblocknotificationcenter/. You’ll obviously need use this on Snow Leopard or possibly with Landon Fuller’s plblocks toolchain (although I haven’t tried that myself).
(Update: I’ve posted a movie on flickr of KVO Block Observing in action)
(update 2: Joachim Bengtsson has posted a great HOWTO guide for blocks. It also goes into some detail about the “self” problem I mentioned and a better solution (__block variables)
Tags:blocks·Cocoa·KVO·snow leopard
- Unboxing so not porn worthy. Developer unit came in a plain white cardboard box.
- Initially thought it was smaller than my iPhone 3G. Then I realised I have a 3rd-party case on my 3G. I’d forgotten how slim the iPhone really was. G1 feels like a brick in comparison.
- Slightly rubberised feel to it is good.
- OMG NEW PHONE SMELL! (After about 18 hours the smell has all but gone)
- Getting the rear case on to insert the battery and SIM card is a major pain.
- The Mini USB and MicroSD covers are almost impossible to open if you have no fingernails.
- Mini USB for charging and syncing is a huge win. I hate the iPhone/iPod USB cable with a passion.
- No mini headphone jack – headphone has a mini USB plug on the end. WTF people?
- I was led to believe the phone would feel cheap and poorly made. While it isn’t iPhone quality it feels pretty sturdy considering it has a flip screen.
- AC Adaptor is just a generic brick. Apple spoils us with their industrial design.
- Activation didn’t work out of the box. I failed to find a cardboard insert with the phone describing how to configure the phone’s APN for activation (did google it myself though).
- Once activated it somehow managed to fetch all my contacts. Which surprised me because I didn’t think I stored any contact information on Google. Need to investigate.
- The camera is so much better than the iPhone’s camera it is not even funny.
- Built-in digital compass is really nice.
- Hate hate hate hate the keyboard. At least it is backlit. I like the “fire and forget” autocompletion on the iPhone. I love having a keyboard while the screen is in portrait mode.
- I hate flipping out that damned keyboard every 2 minutes.
- 90% of the time when I flip out the keyboard I accidentally mash the volume control by mistake.
- Volume controls are too soft and will be too prone to being accidentally mashed anyway.
- Not found any use of multitouch yet – but doesn’t mean it isn’t there.
- Only found a single app using the accelerometer (3rd party Texas Hold’em game). Every other app bases screen orientation on whether or not the keyboard is flipped out.
- Turning off the G1 is silly – 4 or 5 steps
- Dedicated camera button is silly again – and not re-mappable AFAICT.
- Too many icons in the status bar. I don’t know what 1/2 of them mean.
- There are just 3 installed widgets – not found a category in the store to find new widgets.
- I like their “finder” more than the iphones. But both seem underdeveloped.
- The browser is shit. You really get used to the double tap and multitouch features of Mobile Safari. I don’t use Mobile Safari too much (preferring dedicated apps) but it towers over the Android browser.
- The E-mail app is functional – but plain. Cannot swipe to delete mail. To delete mail you seem to have to read it first. Ick.
- In E-mail “message mode” so much screen real estate is taken up with buttons. This is the best Google can do?
- Composing e-mail is plain. Again hating the keyboard.
- Built-in calculator is so incredibly shit. This is definitely a huge 3rd party opportunity (whether it is intentional or not is another matter).
- So far the flipout keyboard (and lack of onscreen keyboard) is the single biggest problem.
- Vibrator is really cheap feel. dont know how to explain it.
- Camera seems to have some kind of autofocus, while pointing it it clicks and refocuses, could be software I guess.
- installing an app warns you about what features it uses: e.g. camera, your location, network, your contact info etc. Which is REALLY nice.
- Dumb! Doesn’t have GPS turned on by default. Have to dig down silly menu system to find it. You would think the Maps app would prompt for it.
- Barcode scanning works well with G1 (3rd party app). Would be impossible with iPhone.
That’s all I have for now. More coming.
Tags:Android·G1·Google·iPhone
TouchCode is mostly a labour of love. I wrote most of the code because it was useful to me at the time I wrote it, or for a forthcoming project. I choose to release it under the an Open Source license because the community as a whole benefits.
I would like to continue improving and adding to TouchCode, but my time is finite and I’m unable to work on it as much as I would like. So when I do work on TouchCode, I appreciate that other people rely on the code and as such I make it a priority to fix bugs before adding new features or components. Other contributors to TouchCode have helped a lot. A lot of bugs and memory leaks have been found and fixed. This is all great. But it is obvious that TouchCode needs more work, it especially needs more unit tests and documentation. To help make time available to improve this I’ve decided to ask TouchCode users for donations via PayPal.
- You do NOT need to donate to use TouchCode (the code is still Open Source under very permissive licenses).
- TouchCode will always remain Open Source. Donations will not change that.
- Donations will be set aside and will allow me to spend more time working on TouchCode – especially the less sexy fun of TouchCode. I will not be using the funds to buy a new MacBook Pro (however tempting that may be).
- Donations will be made with no strings attached. I will not be adding feature X to component Y just because you’ve donated to the project. However if you have an urgent need for something in TouchCode (output support in NSXMLDocument perhaps?) contact me and we can talk.
- No donation too small, no donation too big. Every donation appreciated.
And here’s the PayPal donate button:
Tags:iPhone·iphone development·Open Source·touchcode
October 6th, 2008 · Comments Off · Default
Tags:cocoaheads·iPhone·obama08
I was going to make a more in-depth posting about TouchMap, but then something kind of big happened. The code is however in the TouchCode google code repository. So have at it. (You’ll probably want to check out all of TouchCode, TouchMap currently depends on other code within the repository).
Tags:Cocoa·iphone development·map·TouchMap·virtual earth
The problem:
I make my living by writing iPhone and Mac OS X for hire. I’ve been doing this for a while with some level of success. But ever since the iPhone SDK was announced earlier this year I’ve been getting many, many more work enquiries than I could possibly handle. I’ve often referred enquiries to friends who I have either worked with in the past or whose work I respect. But this ad-hoc system doesn’t scale very well.
The Solution:
To try and make this informal referral approach work I’ve set up a private invite only Google Group called “iPhone Software Professionals”. Currently this group is made up of a handful (more than 10 less than 1000) software developers who specialise in iPhone development (although I’d say all are equally capable on Mac OS X). The group is made up of either people I have worked with personally (and would love to work with again) or people whose work has generated such a reputation that I would have no problem recommending them to a potential client.
The list is currently made up of software developers but I would like to open it open it up to any independent professional involved in the production of iPhone software. This includes, but is not limited to usability experts, graphic designers, quality assurance experts and so on.
The group will probably remain quite small, with new members invited and referred only by current members. There is no commission or finder’s fee involved, the group is just an informal group of professionals forwarding work that would otherwise be rejected.
Looking for an iPhone Software Professional?
So if you have some iPhone software that needs to be written then I think I might be able to find someone to help you out. I might be able to help you myself, but if I have more work than I can handle (which currently is very likely) I’ll forward your request to the group. Either way contact me directly at iphoneswpro@toxicsoftware.com and I’ll try make sure your software gets written.
Update
Please do not request an invite directly via Google Groups. See http://toxicsoftware.com/iphoneswpro/ for information on how to join the group. Essentially it helps if you or your work is known and respected by myself or other members of the group. You can use the email address to send a request directly to me.
If you’re not invited into the group please do not take it personally. I’m trying to keep a good balance between job leads posted to the group and freelancers able to consume the job leads. If the balance is good (or there are too few job leads) we will not be adding new developers to the group.
Tags:consultancy·contracting·freelancers·iPhone·iphone development·iphone freelancers·iphoneswpro
Well, the
project I was so excited about last week has now officially seen the light of day and is on the iPhone AppStore. The project is the Official iPhone application for the Obama/Biden ‘08 campaign (Direct link to AppStore!).
The application was created in less than three weeks by an all volunteer team of ten developers, artists, web designers, quality assurance specialists and project managers. You can see the name of everyone who worked on it in the credits of the application itself.
I started work on the application the day after C4[2] after some very clandestine meetings in Chicago. After about a week of writing TouchRSS code on my own, the project suddenly jumped into high gear, with the indomitable Mike Lee, Tristan O’Tierney and incredibly talented Louie Mantia (responsible for the application’s amazing and distinctive look).
I feel really honoured to have worked with such a great team (see Raven Zachary’s blog posting for links to everyone). The project was a sprint and of course suffered from a lot of ups and downs. But I think we managed to create a really great application in a very short space of time.
Here are some blog postings from the other team members
Official Links:
Tags:
A quick teaser for TouchMap. I’m hoping to release this on TouchCode later today.
TouchMap.mov
Tags:Cocoa·iPhone·Open Source·touchcode·TouchMap
Tags:iPhone
The following tweets are one of reasons why I (despite initial misgivings) really enjoy Twitter.
I can’t talk about the actual thing in question until Sunday 28th at the earliest (probably more like Monday). But I’m very excited (as you can tell by the fact it is four AM and adrenaline is still keeping me awake) about it and can’t wait for it to be released
schwa I want to tweet something of great excitement and interest to many of you. But I can’t. SO pretend I did and JUST CONGRATULATE ME.
about 3 hours ago from twitterrific
lyzadanger @schwa Ditto.
about 3 hours ago from web in reply to schwa
annekate @schwa Congratulations, ya lucky bastard!
about 3 hours ago from twitterrific in reply to schwa
chockenberry @schwa YOU ARE AWESOME BIG THUMBS UP FOR YOU
about 3 hours ago from twitterrific in reply to schwa
SenorDanimal @schwa congratulations Jonathan! (payment can be sent to me via check or cash)
about 3 hours ago from twitterrific in reply to schwa
oleoptene @schwa and @lyzadanger my most discreet congratulations!
about 3 hours ago from web in reply to schwa
tjw @schwa Go code tease, go!
about 3 hours ago from twitterrific in reply to schwa
atomicbird @schwa Congratulations, I’m sure!
about 3 hours ago from twitterrific in reply to schwa
mzarra @schwa Congratulations!!
about 3 hours ago from twitterrific in reply to schwa
sherryness @schwa Nice job! high five
about 3 hours ago from web in reply to schwa
bobtiki @schwa congratulations!
about 3 hours ago from twitterrific in reply to schwa
hjon @schwa Congratulations! For nothing. ;-)
about 3 hours ago from twitterrific in reply to schwa
heckj @schwa Congrats, absolutely and obviously.
about 3 hours ago from twitterrific in reply to schwa
rentzsch @schwa . Fault may be resolved upon submission of actual data
about 3 hours ago from twitterrific in reply to schwa
bsneed @schwa w00!! congrats on [insert neat shit here]!!!
about 3 hours ago from twitterrific in reply to schwa
brentsimmons @schwa Congrats!
about 3 hours ago from twitterrific in reply to schwa -
rcw3 @schwa Grats!!!
about 3 hours ago from twitterrific in reply to schwa -
ashponders @schwa wooo!
about 3 hours ago from twitterrific in reply to schwa -
SenorDanimal @schwa of course this reminds me I need to d/l touchcode before I get on my return flight so I can mess with it.
about 3 hours ago from twitterrific in reply to schwa -
somegeekintn @schwa Oh hey, congratulations!
about 3 hours ago from twitterrific in reply to schwa -
ganyard @schwa Who’s the rock star? You are. You are man. You, you’re a rock star.
about 2 hours ago from twitterrific in reply to schwa -
natevw @schwa [REDACTED]
about 2 hours ago from twitterrific in reply to schwa -
chicagobob @rentzsch ’s congratulations to @schwa totally FTW
about 2 hours ago from twitterrific in reply to rentzsch -
dom @schwa you are superhuman.
about 2 hours ago from twitterrific in reply to schwa -
macdevnet @schwa that was the most awsome tweet ever man, you’ve raised the bar for us all, well done
about 1 hour ago from twitterrific in reply to schwa -
janl @schwa CONGRATS!
about 1 hour ago from mobile web in reply to schwa
simX @schwa is like Bush and his Twitter followers are like the Democratic Congress: he tells them to do things (congratulate him) and they do it 24 minutes ago from web in reply to schwa -
simX OH YES I DID GO THERE I JUST SAID @schwa AND BUSH IN THE SAME SENTENCE. 13 minutes ago from web
Tags:twitter project_v fnda