Our DNA is written in Objective-C

Drawing on UIImages

Jayesh asks:

Thanks for your article on UIImage from UIView.

Need one more favor; I am in situation where I want to draw line or area (e.g. rectangle) on UI Image (e.g. Blue print) and save it again.

Basically I will show image and put circle / rectangle on image showing area in blue print and save it.

How should I do that? Can you please suggest approach, sample codes etc?

So the task is to take a UIImage, make it writable in some way and then make a new image out of that for later use. Off the top of my head, I can immediately think of two ways to do that: with UIKit and with CoreGraphics. CoreGraphics has a slight advantage, being lower level, of being thread-safe. But for a simple graphical addition to an existing image I see nothing wrong with UIKit. As usual you should only do very quick operations with UIKit because it requires to be run on the main thread which is the only thread updating the user interface.

Read more

iPhone 4 Landing in Austria

It’s one of these days there the arrival of a new and shiny Apple toy is diminishing productivity to zero. My iPhone 4 arrived at lunchtime and so I spent my afternoon unboxing and setting up my new iDevice.

I had purchased a black 32 GB iPhone 4 on Apple’s UK store. The kingdom is a tier 1 country which got it at the same time as the US. What’s also great is that the empire’s Apple online store sells the variant without SIM-lock. A necessity if you want to be able to use the iPhone 4 as a phone in your home cellular network. Since I ordered Apple added this paragraph to clarify this:

When you purchase your iPhone from the Apple Online Store, you’ll get it SIM-free. So you can sign up for service with the carrier of your choice and change your carrier at any time

My friend Michael Kaye in London purchased the phone for me (32 GB for 599 GBP) and shipped it via parcel service to Austria. This cost me another 60 pounds, but I had insurance and tracking. The latter was kind of weird, because the original carrier Parcelforce handed off the package to FedEx and so I got incomplete and somewhat strange tracking info. But fortunately it turned out fine.

I’m unboxing the iPhone after the back, check out my YouTube video!

Read more

Hacking UIScrollView Gesture Recognizers

As of SDK 3.2 most of the touch handling code in stock controls has been taken out and replaced with this amazing new technology called Gesture Recognizers. This means besides of using them yourself and creating your own you can also fiddle with behaviors of standard controls if they interfere with your own gestures.

I’m currently working quite a bit on something based on UIScrollView and there I found several things that I needed to tweak.

Disabling Pinch

The first modification I did was to get around a bug in UIScrollView.  I did not actually want user zooming in my scroll view, but just use the setting of the zoomLevel to scale images without having to redraw them. And you can only set the zoomLevel to values between min and max.

So, during autorotation, I reduced the min zoom scale, set the new zoom level and then set min and max both to the new zoom. But the problem with this, as of SDK 3.2., is that if you change the min or max zoomLevel property the scroll silently adds a UIPinchGestureRecognizer to itself via the addGestureRecognizer method that now all views have.
Read more

Service Announcement: Upgrading iOS 4 GM

A not-to-be-named friend asked me:

I would like your opinion the GM build. Should I (not sure how) remove it and then load the new iOS 4.0? I know it wouldn’t have the game center, but I don’t use that anyway. I am afraid if I don’t remove, the software will expire (happened on beta 4 and then I couldn’t use the phone (or back up first) until I could load the latest.

If you’re one of those developers that managed to install the iOS 4.0 Gold Master right after Uncle Steve announced it, then you might wonder if you should update to the really final release that came out just now.

Wait! That’s a trick question…!

Read more

BOOK: The Business of iPhone App Development

A long time ago, in a galaxy far far away … I think around the beginning of the year actually, Michael Schneider asked me to read this book that he collaborated on with Dave Wooldrige.

At this time and until this date this book remains the biggest and most comprehensive guide on what traps there are in the iPhone app business. It took me some time to read the book from cover to cover and then I also was simply to busy and lazy to do this review. And actually there was another reason, that I din’t want to admit to.

I’m by nature an iPhone app creator, not a business person. I had my first app in the store about 2 months after downloading the SDK back in 2008. Making apps is what I love, but marketing them… yuck! Now if this book really was as good as the table of contents looks then this would mean that I had found – rather by accident on twitter – the ultimate guide to everything that I needed to know about transforming my app workshop into a viable business.

Read more

Rendering PDF is easier than you thought

We all know by now that Adobe is almost as evil as …, well let’s say they pioneered a couple of functionalities that where great for the longest time. One being the PDF format which is actually totally built into OSX everywhere. On OSX you’re able to print into a PDF without having to install extra software. Also iOS comes with PDF support and today we’ll look at how we can draw a PDF in a view.

Note: This article examines the native PDF rendering capabilities of iOS, which are very basic to say the least. For a commercial solution to support high-performance PDF viewing, editing, and annotations in your app, we recommend PSPDFKit.

Read more

Xcode 4

In Austria we have a saying “Big things throw their shadows way ahead of them”. While the rest of home-staying iPhone … pardon iOS developers has only seen the Stevenote, a couple of lucky attendees where able to get their hands on a pre-BETA version of Xcode. They are still under NDA when it comes to discussing it, but you know how it is with Twitter, it’s not really possible to keep those things under wraps if people are excited and connected.

And also, since these details are now on the internet and thus public domain, wannabe journalists can scrape the few available details together and summarize them for you, my dear reader.

Generally developers love that Xcode 4 appears to be a total refresh, lots of thought is apparently being put in, all the more reason to look forward to it. Attendees of the WWDC got a download link on the Apple Developer Forums, but us regular folk only gets an error message. Some People think it was changed too much (T, T) for comfort, but a revolution is never easy.

But for the most part you find only happy tweets (T) and comments.  Here’s my rundown on the features we have heard about:

  • Interface Builder becoming part of Xcode for a combined IDE. T T
  • There is a new Counterparts View that is really convenient. T
  • There is a Code Snippet feature, possibly similar to Dashcode. T T
  • LLDB will replace the current GDB debugger. T
  • New LLVM compiler. (2x compile speed improvement. up to 25% runtime speed improvement. On iphone up to 60% faster apps!) T
  • There will be Tabs. T
  • MDI (Multi Document Interface) where you see multiple source files within the same Xcode window. T
  • Great GIT Support. Improved Subversion Support, too. T T
  • You will be able to choose different skins for the IDE. T
  • Revamped project and target settings for choosing build configurations, localizations, deployment target,etc.

Installation will takes about one hour (T). Because of the amount of things you can have on screen at the same time, you might want to get a monitor of at least 27″ in size (T).

Several people (T T) mentioned June 21st as possible avilability date of Xcode 4 as preview version. But I’m sure your buddies who made it to WWDC will let you take their Xcode 4 for a spin. 😉

How to make your Hybrid-App crash for sure

I was quite happy finally getting the new polished 1.1 version of SpeakerClock approved. But there was one problem: people who tried to run it on iPhones with iOS 3.1.3 started tweeting me that it crashes. I was astonished, I was not aware of using anything from 4.0, I just had to set the base SDK to 3.2 to support hybrid mode.

Then I tried out the update on my wife’s iPhone which I kept at the latest released iOS version, 3.1.3. And it crashed. So I hooked it up and had a look at the crash report. There’s something about “doesNotRecognizeSelector”. This means I am calling a method that the receiving object does not recognize. Uh Oh.

Read more

Dr. Touch #17 – “This Changes Everything, Again”

What the Stevenote means for us developers.


The Show Notes aka Script after the break

Read more

SteveNote (Quasi) Live

Like every good follower I shall be glued to my big iMac to listen read the latest news from Steve Jobs when he takes the stage at the WWDC 2010 keynote. Somebody called my a “FanBoi”. But I’d rather be a FanBoy than a Fan of a Boygroup. 😉

Apple is always extremely protective of their resources. So they just won’t exert any efforts in streaming the event but rather post a stream a couple of hours later on apple.com and add it to the Apple Keynotes Podcast even a few hours after that. But that does not mean that you have to wait for the info. The web is your friend.

UPDATE: Send me your Skype name. We’ve established a skype chat channel and there’s already a lively conversation in progress.

Here are some sites that have a proven track record (for me) of relaying what’s going on. I will plaster my 27″ iMac and my 15″ MacBook Pro with these.

  • Engadget live – Great Live Blog with Photos
  • Gizmodo Live – Usually head to head with Engadget on the frequency of updates and photos
  • TWIT Live – Leo Laporte is broadcasting live and if there’s any live video or audio then he’ll get it
  • MacRumors.com Live – they formatted their live bloggingsite ideally for iPhone/iPad

Other Liveblogs (as recommended by Gizmodo) to take your pick from: gdgtArs TechnicaWiredTechnologizer,NYTMac Life, and Apple Insider.

I won’t be making an effort to relay the info, because so many other people are doing that. But I’ll be making notes as to which things are of especial interest and importance to us iPhone developers.