I have no idea what Amazon rankings really mean right around a book launch. Since they weight towards recent sales, I’m sure they spike, so you have to take these things with a grain of salt. But for at least a little while, we have the #1 book in Mobile & Wireless Programming. I promise I won’t keep spamming you all with book updates, but it’s the first time I’ve been at the top of a “best sellers” list.
The Book Is Almost Here
I’ve mentioned that Mugunth Kumar and I have been working on a book, iOS 5 Programming Pushing the Limits. It’s available now for pre-order and should be shipping by 12/20. It will be available in several eBook formats, though I don’t have all the details for that yet. I’m proud of what we’ve been able to put together here. The target audience are developers who have some iOS development under their belts, and are ready to move to the next level. Rather than just focus on the nuts and bolts of getting things done, we cover how to do things well. In the process, we cover a lot of more advanced ground, often of frameworks with “Core” in their names like Core Animation, Core Text, and Core Foundation. We also address practical issues like how to optimize your application for offline work, and how to best handle REST and JSON.
Properly Encrypting With AES With CommonCrypto
Update: You can now download the full example code from my book at GitHub. This comes from Chapter 11, “Batten the Hatches with Security Services.”
Update2: The things described here are handled automatically by RNCryptor, which is an easier approach unless you want to write your own solution.
I see a lot of example code out there showing how to use CCCrypt()
, and most of it is unfortunately wrong. Since I just got finished writing about 10 pages of explanation for my upcoming book, I thought I’d post a shortened form here and hopefully help clear things up a little. This is going to be a little bit of a whirlwind, focused on the simplest case. If you want the gory details including performance improvements for large amounts of data, well, the book will be out later this year. :D
A PandoraBoy Maintainer Emerges
I went out to NSCoder RTP for the first time last night and met up with Josh Johnson, who has been interested in taking up PandoraBoy development. So expect some changes coming up. Probably a move to github. Probably dropping 10.5 support soon. And who knows, it might even really work again.
Looking for a PandoraBoy Maintainer
The whole reason I learned Cocoa in the first place was so I could work on PandoraBoy. It’s a great project, but I haven’t really worked on it in quite some time. As Pandora changes, PandoraBoy becomes more and more broken. I barely have time to look at the patches that have been sent it, let alone apply them. My life has moved onto many other projects.
I’m actively looking for a new maintainer. It’s a good project, and the code base is in decent repair, though I don’t know if it builds with Xcode 4. The system basically works, but there’s a long list of things that could be improved, and some things that are now downright broken. If you’re interested, let me know and I’ll help hand it off. I took it over when I knew next to nothing about Macs. It’s a great place to learn.
One of the Reasons I Like KACE (the New M300)
I don’t usually shill for my company’s products, but I’m really impressed with the new M300 we just put out. It’s an IT management appliance targeted at companies with 50-200 computers. I like how simple it makes setup; reminds me of Apple. Fewer “fiddly-knobs” and more “just works out of the box stop messing with it.” We’ve got the K1000 for those companies who need lots of configuration, but I’m excited to see us get into the SMB space like this. I know most of you don’t need an SMB IT management appliance, but it’s just a pretty cool box and I’m proud to be involved.
Laying Out Text With Core Text
I’m back in full book-writing mode, now working with Mugunth Kumar, who is brilliant. Go check out his stuff. Hopefully we’ll have something published and in all your hands by the end of the year. The book has taken up most of my writing time, so the blog will continue to be a bit quiet, but sometimes I like to answer a Stackoverflow question a bit more fully than I can there.
Today’s question is about laying out text without CTFramesetter
. We’re going to take a whirlwind tour through some CoreText code to demonstrate this. It’s not quite what the OP was asking about, but it shows some techniques and I had it handy. I’ll be writing a whole chapter on Core Text soon.
The goal of this project was to make “pinch” view. It lays out text in a view, and where ever you touch, the text is pinched towards that point. It’s not meant to be really useful. Everything is done in drawRect:
, which is ok in this case, since we only draw when we’re dirty, and when we’re dirty we have to redraw everything anyway. But in many cases, you’d want to do these calculations elsewhere, and only do final drawing in drawRect:
.
We start with some basic view layout, and loop until we run out of text or run out of vertical space in the view.
Wrapping Text Around a Shape With CoreText
CoreText is a very powerful system for laying out text in arbitrary ways. This is going to be a bit of a whirlwind tour of it to help out nonamelive on StackOverflow.</a> I’m working on an advanced iOS book right now, and I’ll have a longer writeup there.
Returning From the Deep Hack
For the last several months, all of my technical time not devoted to my primary employment has been absorbed in a little iPad project. Nights and weekends that I usually would spend writing blog posts, chatting on Stackoverflow, or working on PandoraBoy have instead been spent on one of the more interesting projects I’ve worked on. But now it’s front-page on apple.com, soaring up the charts, and I’m rolling onto other things. Top of my list, when not working on an awesome IM/Phone app full time, is starting work on a new iOS book, but close after that are PandoraBoy improvements, Cocoaphony and Stackoverflow. And maybe a little skiing. And there is that go-kart the family has started building. But still, blogging is up there, and I should have a new build of PandoraBoy out in the next week that fixes up some annoying bugs.
Clipping a CGRect to a CGPath
I’ve been playing with Core Text recently, and one of the things I wanted to do was layout text in an arbitrary CGPath. On Mac, you’d do this with NSLayoutManager, but iOS doesn’t have that so we have to build our own. I’ll discuss Core Text more later, but one of the steps along this problem is how to clip a CGRect to a CGPath. I found several discussions of finding CGPath intersections, all explaining the basic technique. Draw the things you care about into a bitmap context and then inspect the pixels to see where they overlap. Clear enough, but it was hard to find a small code sample that demonstrated this with Core Graphics.
For my purposes, I want the first full-height rectangle within the intersection of the line rectangle and the CGPath. Later I will expand this code to find all full-height rectangles within the intersection (there can be more than one), but this is enough to demonstrate the point.