Sunday, June 29, 2008

Scott Stevenson on "Thinking Like a Cocoa Programmer"

Scott Stevenson over at the Theocacao blog (and no, don't ask me how to pronounce it) has a great little piece on Thinking Like a Cocoa Programmer. If you're new to the Mac / iPhone development scene, this is well worth a few minutes of your time.  Even if you're not new to the platform, it's well worth a few minutes of your time.



Wednesday, June 11, 2008

Ah.... WWDC still

This is making for a long week. I'm a little disappointed in many of the iPhone sessions. I guess, with the amount of hours I've logged messing with the iPhone SDK, there's been only a few nuggets of truly new information, and the questions I do need answered, I'm having a hard time getting anyone to answer. Very frustrating. I understand why the sessions are like this and don't blame them, but it's still frustrating.

In some ways, it doesn't "feel" like a Mac developer gathering this year with all the press, and the huge influx of people new to the platform. In the long run, this is all good for the platform, but there are growing pains to be suffered. But as long as Steve Jobs doesn't turn into this, I guess I can live with it...

I did get a chance to see a presentation by Dr. Michael "Wave" Johnson of Pixar today at lunchtime. It was one hell of an entertaining talk, but it was more than just entertaining - he was saying a lot of things that a lot of people in that room needed to hear (and a lot of people in the software industry in general need to hear). It's really too bad the session was under NDA, because I think everybody who codes or wants to code should see it. If you ever get a chance to see him speak, go out of your way to do so: You won't be disappointed.

They are doing some really cool in-house development at Pixar. I don't think I'd ever be tempted to become an employee of a big corporation again but there are a few places that I would have to give serious consideration to if they ever were to come calling (as unlikely as that is). That team at Pixar is definitely one such place. Though I probably would end up staying self-employed, I would be sorely tempted. It sure looks like a great place to work and Dr. Michael looks like a hell of a person to work for. 

I've complained a few times lately about being busy, but I haven't given much detail because I haven't been able to. Well, apparently, the wraps are off one of the projects that's been eating up my time. This is a big thing for me in a number of ways. First, it will be my first published book; everything I've had published so far has been much shorter in length. It's also great because I get to work with Dave Mark, who's a great writer and all around great guy, and I'm tremendously proud to be working on this project with him. We have a very aggressive deadline, so if you don't see many posts from me in the next two months, you'll know why.

The other big project I've got on my plate has to stay under wraps for a while longer, but I'll just say that it's of similar magnitude and importance to me. I wish I could say more, but I can't. I promise that I'll share as soon as I'm at liberty.




Tuesday, June 10, 2008

More WWDC

Man, I wish I could share some of the stuff from Yesterday. The keynote was, of course, public, and you can go watch it here. But the keynote was all about iPhone, but there actually was a lot of news on the Mac OS X front.  Apple has made a small part of the new "Snow Leopard" functionality public here, but I can tell you that the release only scratches the surface. We live in interesting times and I think they're doing the right thing with the approach they are taking - it's very long-term, and its unusal for a big company to do that.

There are an awful lot of new-to-the-platform folks here this year, mostly pulled in by the iPhone SDK, and a lot of them complete newbies to Cocoa and Mac. Apple seems to have known that this would be the case: any of the iPhone sessions today have been very basic, hardly the level of detail I was hoping for. Even the class intended for experienced Cocoa programmers was, I thought, a tad on the simplistic side. While I did get a few good tidbits, there was not much new for me. There are some more advanced sessions later in the week that I'm excited about, though.

If you are a Mac developer, or want to be one, you really should try and find a way to get out to San Francisco for this event. It's expensive, but worth every penny if you can swing it. Plus, where else you can you replenish your stock of Apple t-shirts?



Monday, June 9, 2008

More Stevenote

You're probably aware of Steve's announcements today, I won't repeat them here, but it was pretty cool. I was in the fifth row, not too far from Al Gore and George Lucas. RDF was in full force, but it's an exciting time for iPhone development. Unfortunately, ther rest of the week is under NDA, and I'm guessing that the SDK NDA will last until the July 11 ship date, so it's going to be a little bit longer before I can cover some of the stuff I want to.



Steve-Note

I'm in line for Steve's keynote at WWDC. We're currently on the first floor of Moscone West, which is better than sitting on the sidewalk outside Moscone, which is what we were doing form 4:20 this morning until 7:00 when they let us in.

Still almost three hours until the actual keynote starts, but pretty cool to actually be here.



Thursday, June 5, 2008

Well, Duh...

If you read the excellent Daring Fireball, or one of the many other Apple-centric blogs, you are probably well aware of how often mainstream media says really boneheaded things about Apple and their products, since it is an oft-blogged topic in the Mac blogging realm. Well, this doozy came today from Newsweek (this quote is on the second page) and nobody seems to have picked up on it:

What we know for sure though is that sales of the iPhone are fading fast and Apple will have to do something very soon to get those phones moving. 
While it is absolutely true that sales of the iPhone have dropped off tremendously, it's not lack of demand, but rather the fact that you can't buy the friggin' things right now, and everybody knows a new version is coming out. Nobody in their right mind buys a new Apple product right before MacWorld or WWDC, especially if the product they want to buy is rumored to be getting a new version. 

Given the rumors of 3G, GPS, redesigned iPhones that will give you a back rub while you talk on the phone with people in the future, it shouldn't be a surprise that nobody's buying the existing models right now. But even if you wanted to buy one now, most Apple Stores, including the online Apple Store, simply don't have them available 




HTTP PUT and NSMutableURLRequest

I've been struggling with a problem with NSMutableURLRequest for an article I'm writing about writing Cocoa clients for RESTful web services. Whenever I use HTTP PUT requests, the form parameters do not appear to be getting passed to the server in the request body. If I did two requests, exactly the same, using PUT and POST, the parameters came up in the POST request, but not the PUT request.

I wrote up a sample Ruby on Rails server and Xcode project to demonstrate the problem and submitted it as "PUT parameters not being passed in body when using NSMutableURLRequest". After being told by Apple that this wasn't happening, I re-tested, thinking perhaps that 10.5.3 release had fixed it. Nope! 

Well, I spent several years working at a large software company fixing reported defects. so I knew that merely re-submitting the same post was unlikely to yield a different result.  Defects are generally not closed lightly, and certainly not arbitrarily, so I dug out wireshark and did a little digging.

It turns out, the PUT parameters are being passed in the body. My description of the problem was not technically correct, even though the code I submitted clearly showed a problem with PUT requests. I took the captured requests for a  PUT and a POST request and noticed a difference: the PUT requests had no content-type header. This is clearly a bug, but it's not the bug I described. I'm going to submit a new defect today, but since I've found a simple workaround for the problem, I thought I'd post it. Here it is:

When using NSMutableURLRequest to do an HTTP PUT request, add the following line of code (req is the NSMutableURLRequest):
[req setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
That's all there is to it. If you add this line of code, your PUT requests will work just fine.





Wednesday, June 4, 2008

T-minus Three Days

I leave for sunny California in three days. And though I lived in the bay area for almost seven years, I'm not going to visit, I'm going to WWDC. 

I'm killing myself trying to clear my plate before I leave, and I have a very busy schedule. I've spent much of the last two weeks trying to wrap my head around Core Audio, with mixed success, and I think I'm trying for some kind of record for number of bugs reports filed with Apple since the SDK came out! I'm concerned that some of the Apple engineers are going to hurt me if they see my name tag. :)

Anyway, if either of the people who read this blog are going to be at WWDC, say hi if you see me.




Monday, June 2, 2008

Web Services Core

I've been doing a lot of work with Web Services Core lately. Although I honestly hate to criticize Apple, I must say they've really dropped the ball with their Web Services support. SOAP web services have moved forward quite a bit, but Web Services Core seems to be frozen at circa 2003 functionality, and WSMakeStubs is even worse.

The first, and more minor problem I've hit recently, is that WSMakeStubs doesn't provide an easy mechanism for supporting HTTP authentication. That's not too big of a deal since it can be worked around with a few tweaks to the generated code. Web Services Core does provide a way to support this, but it's not necessarily something that would be obvious to somebody new to the platform.

The show-stopper, however, for many web services is that there is absolutely no mechanism for specifying attributes for an XML attribute that's passed inside your SOAP envelope. So, if a web service requires some piece of information to be passed in using an attribute, you're pretty much screwed.

There is a way to make Web Services Core do this, but it's such a hack, that you'd probably be better off rolling your own client libraries. It involves writing your own serializer and overriding the XML serialization for the CFTypes you use. It's an ugly hack, difficult to implement and even harder to explain. It's not the type of code you want to maintain if you're likely to have much turnover in your development staff.

I opened a bug report with Apple, but I'm not overly optimistic that they'll fix this, to be honest. They don't seem overly concerned with SOAP web services at the moment. 

This could be a big deal if you're an iPhone developer, though. You see, Apple appears to be trying to position the iPhone into the enterprise by adding Exchange support, and a lot of new iPhone developers that I've met come from a background of working in Corporate IT shops. Many of the web services used inside the corporate enterprise are written using Microsoft tools that support (and even encourage) using attributes in the XML tags in SOAP methods. In fact,a prime example of this is the Exchange WSDL itself. It has required attributes in at least one tag on every single exposed method. This means you currently can't write a Cocoa client for even a single exposed method from the Exchange WSDL using WSMakeStubs or Webs Services Core. You can write one, of course, but it's going to be a lot of work.

I'm honestly concerned about the impression this is going to leave on people coming to the iPhone from .Net, which has very robust Web Services libraries. Many of the new Cocoa developers I've talked to lately have experience with .Net. Of course, the long-time Cocoa developers are trying to convince these newcomers how wonderful Cocoa is, but things like this kind of get in the way of proving that point.