I’m working on a cocoa app that I want to beta test and distribute development builds so I need the app to expire after a certain number of days.
I was looking around and found a great post on Red Sweater Blog about using the compiler macro __DATE__, which inserts the compile date into the code as a date string: Jun 23 2010. This string can then be read and used to determine how many days it’s been sense the code was compiled.
Based on this post I created a class for easily creating apps that expire after a specified number of days.
The comments mentioned some potential issues with times zones which I’ve tried to account for. I’ve also implemented the class with a class method that can be used to compute the number of days left, and a singleton so this data is cached and can be used throughout the app without computing it every time.
Well without further adieu, here is the code. There are some examples of how to use it in the header.
[...] Suicidal Apps: How to break your app deliberately after some time: http://inscopeapps.com/blog/suicidal-apps/ [...]