Sep 13, 2009
When working on the review downloading for MyAppSales I found a situation where I needed to convert NSData I received from an NSURLConnection directly into the NSDictionary which it represents. Neither class really helps you there, there are only two methods to instantiate an NSDictionary from external contents:
Now where is the missing dictionaryWithContentsOfData? Well, it turns out that such a method exist, but it’s way down the frameworks stack burried in Core Foundation. Let’s make a useful category extension for NSData to fix this for our purposes.
Sep 10, 2009
The gist of the updates to the MyAppSales codebase for version 1.0.7 where related to improving performance and lay the groundwork to be able to add new features or rewrite current ones with the least impact. For example I added a method that allows me to dynamically upgrade the DB schema from all previous versions to the current one without losing data. This way I can add new tables to existing databases.
Also I added an AccountManager class which allows me to enumerate and deal with multiple accounts. Currently only the first you set up is checked, until I can figure out a safe way to prevent duplicates or wrongfully detected report duplicates from multiple accounts. I am thinking of doing sort of finger-printing letting the app figure out which apps belong to the same account. Something smart like this is necessary because a user is at liberty to delete an ITC account and also a future import mechanism will be FTP and there you also don’t know which account those files are from.
There where so many little changes that I simply did not want to wait any more to tell you what’s been going on there. So please be easy on me regarding unfinished features. It’s coming, be patient grasshopper!
- ADDED: Experimental support for monthly (financial) reports. Manual import only.
- ADDED: Possibility to lock MyAppSales with a passcode (aka PIN)
- CHANGED: Ssettings are now saved in NSUserDefaults as opposed to a plist in the app’s doc dir
- CHANGED: Split the database code and the iTunes Connect code into discrete classes in preparation for future multiple data sources
- CHANGED: Replaced keychain wrapper with new custom AccountManager class that allows me to enumerate over accounts in preparation for future additional data sources like multiple ITC accounts as well as applyzer, admob et al.
- FIXED: The lower part of the cancel button behind “Empty Cache” was irresponsive
- ADDED: Smart detection of iTunes Connect downtime due to maintenance
- ADDED: now the iTunes Connect cookies are checked to see if a login was successfully as opposed to scraping
- FIXED: Login failing after clearing the cache
- CHANGED: It is no longer possible to combine multiple reports into a single text file for import. The first line of a report is used to determine the report type and dates for the whole file.
If you have a large database and use the passcode lock you might experience a second or so delay right after program start when entering the code. This is normal, and caused by summing app totals being done right after app start. I’ll have to move this to a background process eventually.
If you have multiple old text files to import it is best to feed them in original format to MyAppSales. Should you have several reports mixed into one, here’s a quick shell script that splits those into multiple files and zips them for single-file-importing:
# Usage: ./split.sh single_text_file.txt
cat $1 | cut -f13 | grep / |sort -u > days.txt
for I in `cat days.txt`
NAME=`echo $I | sed -e "s/\//-/g"`
echo "FILE: $NAME";
head -1 $1 > $NAME.txt
cat test.txt | grep $I | sort -u >> $NAME.txt
zip import_me.zip *-*-*.txt
I have begun to tag the releases on the svn repo. In the trunk you will always find my latest experiments. If you want to get stable code you can now get that from the tags folder.
To summarize: In this release you will find a little bit of eyecandy. But I am proud of the passcode locking feature which has only been requested last week and now it’s already implemented. (Honestly I needed it for another project, speaking of reusable code). I am excited to be approaching a state of the code where I can think of adding data from Applyzer, advertisement reports from AdMob or simple add reviews.
Please let me know what you think by either commenting here or raising a
bug report feature request at http://www.drobnik.com/bugs
Sep 01, 2009
I was quite looking forward to getting a chance to improve my already quite satisfying Mac experience to the latest iteration of the operating system. Having bought my new MacBook Pro after Juni, I was elegible for an extra cheap upgrade. So I filled in my serial number and got promised a delivery about a week afterwards. But not being the patient type I figured it would not be a sin to borrow a friend’s DVD and install the new cat. Hey, I own a license, who cares which media I’m using?
Installation was as painless as can be. You pop in the DVD while your Mac is running, click a couple of times and then you wait. After 20% there is a first reboot, then you wait, all together roughly 40 minutes. At first you don’t see any new stuff, except the same welcome Animation playing in a Window instead of full screen. But then you start to see little things. Many little things, in fact enough to warrant a 23-page in- depth technical review on Ars Technica which is great bedside reading making you dream nicely about your invigorated Mac.
I was excited to install the new Xcode 3.2 from the “Optional Installs” folder on the DVD, then I downloaded and installed the latest iPhone 3.1 SDK for Snow Leopard which in contrast to Leopard is just the SDKs and now Xcode. The Leopard version contains Xcode 3.1.4, which for strange reasons does kind of run, but is “not officially supported by Apple to run on Snow Leopard”. Still, I will show you how you CAN compile against a 2.x SDK. After that I will show you Apple really wants you to do, but leaves it up to SDK diggers to tell the public.
Aug 28, 2009
One of the techniques which I have found to be extremely useful are notifications in Objective-C. Using NSNotification to send broadcasts to all objects in your app is something that I did not see in any other language or framework I visited before. Here is a quick recipe to show how to use them.
Think of notifications as a method of informing all your class instances within your app at the same time. Sometimes there is a global change that does not have a single target like you would for a delegate. Without notifications you would have to keep track of all objects to be informed of the change manually, loop through them and call an update method.
To give one useful example: In MyAppSales you can set your main currency so that all amounts get converted into the currency you are used to instead of showing you Japanese Yen. Now what happens if the user chooses a different currency and you have objects like table views, table cells or your own class instances that need to change something whenever the main currency changes. Enter NSNotification and NSNotificationCenter.
Aug 24, 2009
There has long been an open feature request for MyAppSales on the Mantis Bug Tracker for displaying a sum total of units sold and royalties earned. Until now I had thought that I would have to rearchitect the way I am calculating sums, but it turns out that a simple SQL statement is fast enough even with almost a year worth of data in the SQLite database.
And while I was at it, I also made some additional useful additions and some visual changes.
- CHANGED: Look of Apps page changed to be closer to AppStore app
- ADDED: Royalties earned so far and Units sold (coming from Daily Reports)
- ADDED: Sums are being recalculated when there are new currency exchange rates and after sync
- ADDED: Smart Auto-Sync. When started the app only communicates with iTunes Connect if there has not been a new report downloaded today.
- ADDED: “Empty Cache” button on Settings page removes cached app icons, chart cache and other temp files that might have gotten left over in document directory. This also causes the app names to be reloaded from iTunes.
As usual you can update your source code directly from the Subversion repo.
Aug 23, 2009
Once you get smart enough to build multiple apps from the same project you probably have to wrap your head around the concept of #define and #ifdef to conditionally activate and deactivate portions of your code. What is somewhat unnerving is that the target build settings change their appearance seemingly uncontrollably and I took a while to work out what triggers this morphing.
The difference lies in what settings you choose in the upper left hand corner of XCode. Only if you select the “Base SDK” setting then the dialog is the most user-friendly.
The build settings for the active target can no be reached by right-click on target, Get Info, build tab. Or alternatively menu option “Project”, “Edit Active Target”. I discovered three places where #define statements can be placed. I am going to show them to you and make a recommendation as well.
Aug 22, 2009
I am extremely pleased to announce a major new release of AntiCrack. While the implementation details have changed very little our new lead developer Fabian Kreiser has rewritten AntiCrack from ground up to obfuscate it to the extreme. Also he researched and developed two additional technologies which should immediately make your mouth water:
- Denial of Debuggers. This makes it impossible for Crackulous to remove encryption.
- Checking of binary encryption. The encrypted envelope put on by Apple in the review process is now checked for integrity.
Previously existing AntiCrack 1.x users are getting the update for free, for everybody else the minimum donation has been increased to 30 Euros. I switched from Dollars to Euros because the increasing weakness of the Dollar started to get on my nerves.
1.x versions of AntiCrack did not really prevent cracking of apps but provided a comprehensive and easy to implement toolset allowing users to dynamically adapt their app’s featureset to “Lite” once a crack was detected. The groundbreaking 2.0 release also prevents cracking in the first place. This again makes it on par with the professional Kaliap copy protection service offered by Ripdev.
Personally I believe it’s now even superior because you get full source code for AntiCrack, don’t have to pay recurring charges and you don’t have to register all new apps and app versions with an online service. I’ve updated the AntiCrack product description page if you would like to read more.
Aug 22, 2009
The version with three ones is always something special for me. That’s why I added several features to LuckyWheel 1.1.1 that have long been requested.
- ADDED: Button to turn on/off sound effects, so you can now listen your your music without disturbance
- ADDED: End-Of-Round Screen which shows total standings so far
- CHANGED: You no longer loose all your previous points when hitting “bankrupt” but just the current round ones
- CHANGED: Game state is always being saved even when on the End-Of-Round screen. Continue then starts with the next round. If this already was the last round then no continue is possible.
- CHANGED: A new design for the buttons to replace the previously used blue standard buttons
- FIXED: 2 minor spelling mistakes corrected in proverbs
- ADDED: Lite Version now showing ad banner whenever a computer opponent has his turn.
- ADDED: End-Of-Round screen also shows an unobtrusive ad.
Since the Lite version is constantly being downloaded around 400 times per day I gave in to the temptation and added AdMob advertisements. I think they will make waiting for an AI opponent to finish less boring. When it’s your turn they always make room.
And to say “Thank you” to all those people who are downloading the Lite version we have doubled the number of available proverbs to guess for free!
Both versions have been submitted to Apple. Hopefully it can get approved soon so that you can reap all those benefits.
Update September 4th: After 13 days both updates have been approved and are now in the app store.
Aug 18, 2009
Do you really understand when you need to retain and release some object? And what about autorelease? It took me around 3 months before I grasped when to use autorelease and now it’s second nature to me. But when I needed to explain to a coding buddy I was stumped. I found that my approach was one of feeling rather than knowledge.
So I decided it was time to do an experiment to visualize what happens to the retain count and when an instance is really released. So see what’s happening to our crash test dummy class I made a TestClass that overrides all the important methods so that we get an output to NSLog what is happening.
First I want to demonstrate how the retain counter – present in all Objective-C classes – is used to automatically determine when the instance can be freed from memory. Then I am going to show how to use a factory method which returns an autoreleased instance to make your life easier.