Objective-C has several powerful methods of working “Meta”. Besides of handling methods and objects themselves you can also save a method’s signature in a variable, and call it later. That’s a “selector”. Or you could construct an object representing the entire call of a method, including one or multiple parameters and then use this object in place of the actual call.
Why would one do such a complicated thing? Well, there are several pretty useful scenarios where it is useful to know this technique. The main benefit of this method is that you can construct method calls during runtime using information that you only get while your app is running.
Personally I was most at the edge of my seat at the “Voices that Matters Conference” in Seattle when Rod Strougo showed us how to make a physics-enabled game with Cocos2D and Box2D in under an hour. It really was as sexy as he sounds. Eros did what every good TV-cook would do, he had most things already prepared. On the flight home I wanted to see if I could just take the physics part (without Cocos2D) and make a UIKit app with it.
The goal of this experiment was to have a UIView with multiple square subviews of different sizes that would start falling as soon as the app starts. The first tricky part is how to add the latest version of the Box2D physics engine to your iPhone project. Then we need to mediate between the different units and coordinate systems of UIKit and Box2D. Finally when we got it all running, we also want to add the current gravity vector to affect the boxes.
My trip to Seattle was great, some of the talks on the conference where indeed worth my while and my host Kevin proved to be extremely hospitable. Something that did almost shock me in the beginning was being approached by half a dozen people individually who came to me to thank me for my blog. I don’t see myself as a celebrity, but I guess with 500 people stumbling upon your online ramblings, chances are that somebody will recognize you, especially if you attend an iPhone-related conference.
These are a few of the nice people that I had the presence of mind to get a picture with after they thanked me and told me that they are reading my blog. Thank you! I appreciate your appreciation. 🙂
I did not get a chance to write anything useful since Seattle for several reasons. First I lost 2 days due to travelling back. One day was literally stolen from me because I had to travel back to Vienna to deal with the aftermath of a break-in into my jumpbase there. The following two days where a blur, I only faintly remember buying a parasol for the deck that our father-in-law built for us while I was away.
Most of the day yesterday I spent with writing invoices for the iPads I brought home for 3 colleagues and rewriting DTAboutViewController to be allow for server-side updating of any plist. And now it’s already weekend, the only useful thing I could do was write a lengthy post for my German personal blog and this one article here.
Please be patient with me while I still try to get back on firm ground. On the plane from Seattle I managed to put Box2D into a UIKit app to have buttons be “physical”. The recipe for this will come soon.
Provided that my stroke of luck continues, I will be in Seattle, WA, USA this week. Currently it looks like I was extremely lucky having booked my flight leaving Tuesday instead of Monday. Had I booked Monday’s, my flight would have been fallen prey to volcanish ash from Ireland.
Towards the weekend I’ll be at the Voices That Matter iPhone Developer’s Conference and until then I hope to meet up with several fellow iPhone geeks who happen to live in the general area. Probably do a fair bit of sightseeing, as I have not been to Seattle before. And if possible fill the empty half of my suitcase with iPads. 😉
So if you are in the general area, drop me a note. If you require my services please be patient until I return.
Dr. Touch is waiting to see if he can fly to the US, there’s a volcano in the way. At the same time Apple unleashes hell in their developer agreement, delay of the international iPad release and lightning-fast new laptops. Today Mike Vallez is my special guest, we’ll talk about iPhone app marketing and his new eBook Secrets to Effective iPhone App Marketing.
If you purchase a component from the Dr. Touch’s Parts Store you will receive a quick start guide which includes the access details to the Subversion repository that keeps my code. The address of the repository uses HTTPS protocol, which confuses some people into thinking that they could use a browser to download the files.
That’s why I made this video showing how to properly set up your Xcode to get the source for any part onto your harddisk.
The advantage of following this guide is that you end up with a “working copy” of the contents of the repository. That means that you can simply pick “SCM – Update Entire Project” and you get your copy updated to the latest version.
There are generally several methods how you could add external code to your own project, besides of simply copying it. The problem with just copying is that it’s quite hard to keep all the individual copies of a framework updated in all of your projects.
In my case I am continuing development on most of my components if I add them to one of my own apps, but I don’t want to have to make all additions that I put into the new project into the component project a second time. Development is boring if you have to repeat steps. Surely there has to be a method to have the updates stream back from the app project to the component project.
In fact, there is. The technique to use is called …
Previously I explained how to make a static library that simultaneously supports multiple different CPUs. At that time I was ignorant to the reason why there are no means to make iPhone frameworks. But I did not give up searching, especially since apparently a few individuals seemed to have pulled it off without properly documenting their method for others to duplicate.
The only guide I found is from two years ago, but I was able to verify that it works and so I will document it in an article so that many more people can use this great mechanism. But first, let’s briefly explore what it really IS that Apple does not want us to do. The generic statement that you can read on thousands of pages is “Apple does not want you to make iPhone frameworks”.
But is that really so? It turns out, this statement is not entirely accurate or rather specific enough to be the truth.
Seems there is an ever-growing community about my little tool GeoCorder which I originally made to get GPS data for testing. It evolved into a light-weight utility many people use for geotagging DSLR photos.
A user informed me that I messed up with the 1.0.4 version of the free variant. Seems both versions got out of sync. The only difference should be that the regular version costs $1 and the free versions has a banner ad. So I went in and fixed a couple of things.
Fixed some memory leaks
Updated AdMob framework in free version
replaced a deprecated function
fixed the free/paid inconsistency
Now all the new features from 1.0.4 are also in the free version as it was intended.
UPDATE April 16th: I had to self-reject my binary because it appears that there was a bug in the ZIP routine. I also added an extra switch to not record events when you are not moving. I removed the 1 Meter setting for the distance Filter because it looks like CLLocationManager ignores that. This gets replaced by the switch.
UPDATE April 17th: Self-Rejected another time. User asked me to change the XML Version to 1.0 for compatibility.
For some reason Apple reserves the ability to create iPhone frameworks for their own use. They are a very useful ability to have because they package headers together with a universal binary. „Universal“ meaning that you get binary code for multiple platforms rolled into a single file. Frameworks are also dynamically loaded which means that less binary code fills up your memory as only stuff is put there that is actually needed.
But alas, no frameworks for us.
Until now I am selling my components in the Dr. Touch’s Parts Store as source code which at the same time means that I could not provide demonstration versions to try out in your own code. If you have the code, what incentive is there to pay the price?
It has been suggested to me by several people independently to make a static library to solve this problem. Could be time- or otherwise limited, but then people could try the parts out and see how well they fit with their own work.
Also next to still offering access to my repositories at full price, I could be selling indidual versions without right to upgrade to get started at a substantial discount. Later if you find that the component really IS worth what I am asking for, you could upgrade to the lifetime upgrade plan via the SVN repo.
Another reason to figure out this Static Library Magic is so that I can bundle my own utility classes that I keep adding to and improving in a central place. This gives me the choice of adding an external SVN reference or to simply copy the static library into my new projects.
In this article I am describing how to create a universal static library for both Intel and Arm architectures, how to glue them together into a single file and how to add it to a new demo project.
I’ve been approached by several parties asking for a component to capture live video. I did my homework but had to find that without access to a hardware-based video encoder it is not possible to get real time frame rates on iPhones.
Interviewing the maker of the ShowTime Video Recorder app for iPhone 2G and 3G enlightened me a bit as to what tricks they used to pull off their app. They use AVI containers for JPEG frames and PCM audio. Other people seem to have a bit of success with compiling FFMPEG on the iPhone. But generally MPEG4 does not use less CPU power than encoding JPEGs, it uses MORE, causing even worse frame rates for live video.
And that’s ignoring the licensing problems you get when selling an app that has a h.264 encoder. A double-whammy in non-feasability for FFMPEG, all the more reason to find out the truth of the matter.
So we set out to build DTVideoEncoder to see for ourselves what kind of performance we can get. Unfortunately it turns out that even on a 3GS we are getting a maximum frame rate of 5 frames per second when encoding live screenshots. Polar Bear Farm hinted that they are only able to get their performance (of around 6 fps) because of heavy assembly-optimizing the JPEG compression library . But they communicated a disinterest in licensing it for us to put into a sellable component.
So we were stuck. Until actually somebody told us that instead of live video encoding he just wanted to add JPEG files to an AVI container plus audio. Because the JPEG files where already compressed he would not face the bottleneck of JPEG compression. Suddenly this specific use case reinvigorated the project.
Kris Harris – maker of the 8 Track Mind iPhone game – went back into the depths of the AVI documentation and polished up DTVideoEncoder to be usable for offline encoding and added the requested capability of adding an existing PCM audio file as soundtrack. Kris is a great developer and his code is awesome, I’m glad to have him on my Dr. Touch Core Team.
Here’s a demonstration of the Demo app that you get with the component.
DTVideoEncoder does not have any external dependencies. Because the external JPEG compression library did not yield any performance improvement over what’s built into the SDK we chose to go with the on-board method.
Hours and hours worth of research and coding went into in this simple to use component to warrant a price tag of several hundred dollars. But because of the limited utility we we set the price to the lower end of the spectrum, at 250 Euros. It might enable one or more interesting uses of offline-video on iPhone or iPad.