PrEV
Thoughts from a NeXTStep Guy on Cocoa Development

What a week...

May 16, 2008 by Bill Dudney

My server got hacked or a DNS entry go hosed somewhere but starting about Wednesday my little mini that could started processing between 600 and 1000 hits a second. Looking for adverts. What is really strange is that my Apache instance was returning 200 instead of 404. I asked around and several people told me I needed to reformat and rebuild the server. So I shut down on Wednesday night around 5:00pm and rebuilt on Thursday. After rebuilding everything I turned the web service back on (i.e. started apache) and what do you know my hit count shot up to 300 to 600 hits a second. Arg..

So then I stared looking elsewhere for the issue and thanks to my responsive hosting provider I got switched to a new IP. Everything went back to normal. So it looks to me (though I'm no expert) like DNS was hosed somewhere which was routing those request to me. What I never understood was why was apache (after a fresh reformat, reinstall) responding with a 200 for URL's that clearly did not belong to my server. If anyone has any ideas I'd love to hear them.

So almost everything is back to normal now. There are still problems with mail but I hope to get that sorted out shortly.

Permalink     Add A Comment

Woot!

May 01, 2008 by Bill Dudney

iPhone, key arrived, os installing, nothing to be said, NDA and all that, very excited...

Lame attempt to be funny, hard to be silent.

Permalink     4 Comments - Add Yours

Colorado Software Summit - iPhone talks accepted!

Apr 15, 2008 by Bill Dudney

I've been speaking at CSS for five years now (I can hardly believe that!). And I'm totally stoked to say that I'm going to get to again this year. Its going to be a slight change of topic for me though (and part of why I'm so excited).

This year I'll be talking about iPhone development instead of Java stuff, I'm really looking forward to it. Here are the two topics/abstracts that were accepted.

Core Animation on the iPhone

Core Animation is what gives the iPhone its distinctive and amazingly beautiful animated user interface. This session will focus on getting you up to speed on how animation on the iPhone works and how you can take advantage of it in your own applications. We will cover the various animation types and how to control their timing. You will also learn how to make animations that look and act like the would in the real world. The iPhone is an amazingly exciting platform and Core Animation is one of the technologies that make it what it is, come to this session and learn how to build applications that take advantage of this really exciting technology.

Building Location Aware Apps on iPhone

Ever get out of the cab and know there must be a Starbucks within 2 blocks of where you are standing but not sure which direction to go to get there? Well with the location aware API built into the iPhone you can find not only where you are but what direction you need to go to get where you need to be. In this session we will cover the API's that make these kinds of applications possible. We will also go over the best practices of how to make your application a good citizen on the iPhone when using the location API's.

I can't wait and I really hope to meet many an iPhone hacker at there!

Permalink     5 Comments - Add Yours

Boulder CocoaHeads Tonight

Apr 08, 2008 by Bill Dudney

Tonight I'll be discussing Core Animation at the Trident Cafe with the fine folks @ the Boulder CocoaHeads. If you are in the area would be great to see you!


View Larger Map Permalink     Add A Comment

Keyframe Animation

Apr 03, 2008 by Bill Dudney

I have been doing some keyframe animations lately and figured it would make a good entry.

Keyframe animations are cool because they give you more exact control over the way your layers animate. The basic animation does a linear interpolation between the 'start' value and the 'end' value. Which works great in many if not most cases but some times you want the path your animation follows to be something different or more sophisticated. The keyframe allows you full control over the intermediate values of the animation.

Whereas the basic animation does a simple linear interpolation the keyframe allows you to specify values at intermediate times so that you can fully control the value during the whole animation. Keyframes have played a part in animation since the days of hand drawn movies. Senior artists would draw the 'key frames' for a scene and then junior artists would fill in the required frames to make the animation smooth (sometimes this process is called tweening). The keyframe animation takes care of the tweening for us we specify the 'key frames' and it does the rest.

Another cool thing is the 'value' that the keyframe can animate is anything that the basic animation can animate. Specifically that boils down to any property of types number, point, size or rect. So for example if we wanted to animate the opacity of a layer we could specify several different values (i.e. 0.25, 0.50, 0.75) that should be reached at specific times during the animation. The keyframe animation would then interpolate between each of the values that we specify.

Another aspect that is really cool is that we can use CGPath's to specify the values instead of discrete values. In other words instead of specific values at specific time points we can use a path to specify the values. For example we could animate the opacity of a layer with a bell curve, start transparent, fade up to some opacity value and then fade back. We can also use the paths to animate CGPoint and CGSize values. In this case the x value of the path becomes either the x or width value and y becomes the y or height values.

In the example we will have a layer move back and forth across the window. Here is a screen shot of the app running.

The white line is a bezier path that we are using to animate the movie layer across the screen. Its drawn simply so we can see it in greater detail. Here is the code used to create the path.

  CGMutablePathRef path = CGPathCreateMutable();

  CGPathMoveToPoint(path, NULL, _point1.x + _movieSize.width * 0.5f, _point1.y);

  CGPathAddCurveToPoint(path, NULL, _controlPoint1.x + _movieSize.width * 0.5f,

                        _controlPoint1.y, _controlPoint2.x - _movieSize.width * 0.5f, 

                        _controlPoint2.y, _point2.x - _movieSize.width * 0.5f, _point2.y);

  if(NULL != _rightBoundKeyframePath) {

    CGPathRelease(_rightBoundKeyframePath);

  }

  _rightBoundKeyframePath = CGPathCreateCopy(path);

  CGPathRelease(path);

  

  path = CGPathCreateMutable();

  CGPathMoveToPoint(path, NULL, _point2.x - _movieSize.width * 0.5f, _point2.y);

As you can see it straight Quartz path creation code. We then place that path into a keyframe animation like this;

  CAKeyframeAnimation *animation = [CAKeyframeAnimation animation];

  animation.duration = 2.0f;

  if(YES == _atLeftEdge) {

    animation.path = _rightBoundKeyframePath;

    // the rotation mode causes the layer to rotate along with the slope of the path

    animation.rotationMode = kCAAnimationRotateAuto;

  } else {

    animation.path = _leftBoundKeyframePath;

    // since the path is reversed, rotate at 180 degrees off

    animation.rotationMode = kCAAnimationRotateAutoReverse;

  }

  _movieLayer.actions = [NSDictionary dictionaryWithObject:animation forKey:@"position"];

Now when ever the position of the layer is changed it will follow the path instead of the default linear interpolation. There is a lot more to be said here but this at least gives a quick intro do using the keyframe animation. Here is the code.

Have Fun!

Permalink     3 Comments - Add Yours

Late Night Cocoa - CA Podcast Online

Mar 27, 2008 by Bill Dudney

Scotty of Late Night Cocoa podcast was kind enough to have me on. His interview of me is online here.

We talked about a ton of stuff but mostly Core Animation.

Permalink     Add A Comment

He's dead Jim!

Mar 25, 2008 by Bill Dudney

Just checked in the last errata pass, last chapter, last verse. It's finito. I still have the iPhone chapter to do but i'm going to take a breather for a few days and get in some very nice spring skiing at Breck.

Permalink     3 Comments - Add Yours

Making Sausage er um a Book

Mar 25, 2008 by Bill Dudney

Making a book is always a huge undertaking. The reviewers really help make the book, helping the author notice where a faulty assumption is made or some such. I have been very fortunate to have a great set of reviewers for my Core Animation book. I wanted to say a special thanks though to Chris Adamson for really digging into the QuickTime capture layer code and helping me make the best example possible.

Thanks Chris!

Permalink     Add A Comment

Prag Prog Podcast

Mar 25, 2008 by Bill Dudney

I seem to be podcasting a bunch lately, which is really fun.

The latest entry into that is here.

Permalink     1 Comment - Add Yours

Brainwashed into acting ordinary?

Mar 20, 2008 by Bill Dudney

I just found this on Seth Godin's blog. If you have not read it you should (both this entry and his blog in general).

So many people don't get it. Do something, do your best, put it out there, get criticized, suck it up, do better, don't give up. As Churchill said 'Success is not final, failure is not fatal: it is the courage to continue that counts'. This is one of my favorite things about the mac indie community. People dare great things.

WWDC 2007 I went to the indie talk that Scott Stevenson put together and blogged about it here. It was packed with people daring great things.

Going back to Seth's post, he says have a great project, a blog, a reputation whatever. He is talking about daring great things, risking something, going public. This as much a reminder to me as it is a pleading with others. Dare great things. Go for it, just do it. If you don't ever step out on a limb and risk then you will not ever achieve great things.

If you have not watched this;

You should.

Make something outstanding, stop acting ordinary.

Permalink     Add A Comment

Mac Developer Round Table

Mar 17, 2008 by Bill Dudney

Scotty was kind enough to have me on the Mac Developer Roundtable tonight. If you are interested in WWDC or iPhone SDK please have a listen. It was tons of fun! Thanks again Scotty!

Permalink     Add A Comment

New Beta Release

Mar 12, 2008 by Bill Dudney

Well on the way to being done a new beta of the book has just been pushed. Everyone who has bought the book (thanks, BTW!) you can grab an updated copy on your account page here. For everyone else you can grab a copy here.

I'm hard at work on the last chapter covering what is different in the newly announced SDK and the existing CA stuff on Leopard. Can't say more but you should check out the announcement.

Permalink     6 Comments - Add Yours

New iPhone Game - iScramble

Mar 10, 2008 by Bill Dudney

My wife just released her 5th iPhone game here. Its a word scramble game that has several different themes and really nice pics in the background. Some of them might take a while to load over Edge (where is 3G anyway?:). If anything is particularly bad please let us know.

Permalink     Add A Comment

Java On iPhone...

Mar 10, 2008 by Bill Dudney

So I read the news that Sun was going to put Java on the iPhone and thought, great!

What I'd really rather see though is Sun put the engineering resources behind putting Java 6 on the Mac and take that responsibility off Apple's plate. Apple is slow to get Java out the door and honestly as a long time Java guy on the Mac I don't really care that Swing looks 'like a mac' on the Mac. Sun could just port the 'native' Swing look and feel (on top of Carbon or Cocoa which ever is easier) and call it a day. Very few Java apps are visual anyway, in my experience it is primarily used to build web sites not fat clients.

I know most Cocoa/Mac programmers don't really care about Java anyway but over the years Mac's have become ubiquitous at Java conferences and I'd hate to see Mac loose the geek chic that its won in the hearts and minds of the Java crowd because there is no Java 6. So anyway here is my small voice saying get the JDK on the Mac and then we can worry about Java on the iPhone.

Permalink     3 Comments - Add Yours

iPhone Apps

Mar 08, 2008 by Bill Dudney

I am totally excited about the iPhone Roadmap. The 'enterprise' level features will get the iPhone in more people's hands in more businesses. More halo effect here we come. I could see this even being part of a push to get Mac's into the enterprise as a unix box that 'just works'. Despite the general lameness of the corp environment selling Macs is good for Apple and good for us so I for one am all over the concept of the 'enterprise mac'. I started my professional software life building custom IT software on NeXTStep on the first round of slabs and that was none too shabby of a gig...

On the other hand, enterprise mac thoughts are not the really exciting thing for me. I am really pumped about the SDK and the fact that Core Animation is there. From looking at the iPhone its kind of obvious that CA is a big part of the UI but its great to see that the API is exposed in the SDK. At about 25:30 in the keynote Scott Forestall says 'we built it in may ways for the iPhone' and 'almost every animation you see on the iPhone is built on top of CA'. That is great news! When you learn CA you will be able to transfer that knowledge straight into building iPhone Apps. There is of course a lot of detail (and I can't talk about it cause of the NDA, sigh...)

Apple doing the App Store as a distribution system is going to be a game changer. We no longer have to worry about hosting, payment infrastructure etc etc. The fact that it costs 30% is cheap IMO having had to deal with a sudden uptick in my bandwidth and server requirements. Jens Alfke has an interesting post about doing apps for 99 cents. That is an impulse buy point for sure. I'm not sure that I'd want to build something useful and sell it for 99 cents though. Sure in 2 days you could crank out a simple app that does one thing, but I don't think it could be made to do it well in 2 days. There are all those pesky power and low memory considerations among others that make building for the iPhone different enough from what we are used to... In any event 99 cents or $5.99 the App Store is going to be a whole new world.

I for one can't wait...

Permalink     Add A Comment