Neonscape 1.1.2
Neonscape 1.1.2, a mostly bugfix release, has hit the App Store – grab it while it’s hot.
In this release:
- I have adopted Rhys’ suggestion to improve the Calibration UI, and the high score UIs
- The calibration is more effective (shameful I know… but the previous calibration code had one rather large (yet simple) flaw which rendered the averaging useless).
- Non-latin characters can be submitted to the global leaderboard (congrats to ?? [ed: it seems however that they can't be submitted to WordPress! [ed: ok, fixed, just had to update my database]] 巴士 for the first user to utilise this)
- Anti-cheating methods have been implemented on the global leaderboard
The App is pretty stable now I think. Neonscape 1.2 is in the works which will have a pre-game options screen for the user to tweak the starting speed (amongst other things), and potentially a new graphics theme and new sound. The price will be hiked for the 1.2 release – so grab it while it’s cheap!
Sending emails on the iPhone with attachments
Sending an XML document from the iPhone is a non-trivial exercise. While Apple can add attachments (e.g. the Photo application), us poor developers do not have this luxury.
To send you will need to firstly encode and escape your data using this code, where yourString is your string. This code is useful for escaping any data sent via HTTP URLs. Thanks to Firefly for the code (he provides a complete sample of how to launch the Mail app with your custom message which I have also used).
NSString *reserved = @”:/?#[]@!$&’()*+,;=”;
return [NSMakeCollectable(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)yourString, NULL, (CFStringRef)reserved, kCFStringEncodingUTF8)) autorelease];
Once encoded, you will probably need to send it using a POST HTTP request as the data may exceed the limits of a GET HTTP request.
Doing that is a little more involved, here’s my code based off these two useful samples
NSString *reserved = @”:/?#[]@!$&’()*+,;=”;
NSString* escapedData = [NSMakeCollectable(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)data, NULL, (CFStringRef)reserved, kCFStringEncodingUTF8)) autorelease];NSString* httpBodyString=[[NSMutableString alloc] initWithFormat:@”to=%@&DATA=%@”, emailAddress.text, escapedData];
NSString* urlString=[[NSMutableString alloc] initWithString:@”http://domain/script.php”];
NSURL* url=[[NSURL alloc] initWithString:urlString];
[urlString release];NSMutableData *reqData =[[httpBodyString dataUsingEncoding:NSUTF8StringEncoding] retain];
NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];
[url release];[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:[NSString stringWithFormat:@"%i", [reqData length]] forHTTPHeaderField:@”Content-Length”];
[urlRequest setHTTPBody:reqData];
[httpBodyString release];[webView loadRequest:urlRequest];
The last line I am particularly proud of. Sure you can do NSURLConnection *connectionResponse = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self]; but then you have to handle the results problematically and NSURLConnection returns raw binary data which is a bit annoying.
So what I do is simply load it into a UIWebView so I can view the results (or errors) from my PHP script. In the final version I’ll just hide that web-view or even keep it for user feedback. The UIWebView handles all the delegate methods. Even if you do want to handle it in code – I suggest you use this as a way to debug your PHP script.
Almost done – now we need to actually send the email!
This PHP script is a very good example of how to send email with attachments, very easy to tweak to accept your $_POST data (and not load it from a file), and change the attachment type to XML.
And that’s it. I couldn’t find all this info in the one place – as you can see by all the link, so here it is!
Manual iPhone Backup / Extract
Confused about exactly what happens and how regarding the iPhone App data backup?
Firstly, read Apple’s FAQ
To initiate a backup (these are by default automatically done regularly but sometimes you want to do one anyway), right click on the iPhone in iTunes and click “Back Up”
Essentially, the iPhone backups are stored in a compressed SQLLite format on your HDD (on mac, /Users/yourusername/Library/Application Support/MobileSync/Backup/). So if you want to backup your backups, backup that directory. It’s in your home directory, so Time Machine will normally grab it unless manually excluded.
Now if you’re a developer or just a curious individual, you may want to peek inside those files or extract the data manually. This is quite possible because they are just SQLLite data files. Check out this awesome iPhone backup extraction software for mac. Be sure to send this guy a few bucks as a thank you. You can also do it the old fashioned way with a perl script. I found the perl script however didn’t convert all of my backup.
Actually modifying the data and sticking it back on the iPhone however I don’t believe is possible as it cryptographically signed to protect integrity (which is good for us developers).
Remember as a developer you chose to store files in the users “Documents” or “Cache” directory. Be nice and put anything that doesn’t really matter in the “Cache” directory to save the user’s backup time when syncing with iTunes.
New Life, New Theme
To celebrate the lunching of my ‘roll-your-own’ round-the-world working holiday, I present to you, my highly esteemed reader, a newer, bluer theme for Omega Delta.
The city in the photo is Hong Kong, taken last year just before the Olympics.
So far it has been great. It’s a little hard to concentrate on my paid work with a city and it’s culture to explore – and when I am working, my own projects – but I’m getting there. No choice really if I want to have fun in America.
Fireworks
Two nights ago celebrating the end of the new years celebrations there were fireworks everywhere, mostly sound-based ones – at first I thought it was coordinated, then found out it was just private citizens lighting fireworks pretty much everwhere. Only that could explain how they could be going on for hours… Many were thrown out of windows, someone nearby had a display going on a narrow footpath, your choice was either wait, or run!
But it seems there are reasons for the regulation that stops this sort of fun back home. Quite sad as a fireman died.
objective-c dynamic invocation
Useful stuff to know: dynamic invocation in Objective C.
iPhone App Piracy – should I care?
Pirating iPhone apps is pretty easy – unfortunately for us developers.
In certain countries such as the one where I am now most iphones come preloaded with hundreds of games.
Neonscape’s pirated app was in the Google top 10 search results for a while.
Now it’s actually possible to detect the cracking – at least for now (until the crackers get better).
The question is should I care? If my app dies after a few minutes on the cracked version will that help my sales? Sure if *everyone* did this it might – but they won’t – so should I? The guy who bought the iPhone preloaded with 200 games won’t exactly go and buy the game legitimately if it dies – he will just delete it and play another.
Freeview Crap
Well this doesn’t really affect me anymore but I was still curious if Au TV would improve at last. It looks like it isn’t, in fact it’s probably an deprovement given that Ten HD with it’s sifi programming will shutdown
Actually, it’s really 14 channels because Network Ten intends to ditch its Ten HD high-def channel on March 26 and replace it with One HD screening 24 hour sport. Ten’s new second SD channel – One – will be a simulcast of the HD sports channel. As a result, sci-fi fans will no longer have access to the extra sci-fi content that’s been screening on Ten HD at night, such as Buffy and The X Files, plus the sci-fi programming on Ten’s primary channel will no longer be available in HD. This has already started, if you look at the TV guide you’ll see Ten and Ten HD only break simulcast for sporting events. I reckon all this will do is drive viewers back into the arms of BitTorrent, where they can download all their favourite shows in high-def direct from the US.
Creating a Lite version
very useful tutorial on creating lite versions of iPhone apps (dev forum thread here).
At first I thought a lite version would decrease sales because people would play the Lite version instead of buying the game. Turns out my logic was wrong. Sure people may do this – but it’s better to have 100 people play the Lite and 5 buy the game, than just 1 person buy the game! Plus when there’s a Lite version of an App I’m interested in I will always download it to try before I buy – if there isn’t then it forces me to do a little research first or punt $1-4, and I have to say I’ve punted a few times and been dissapointed.
Neon Lite is in the works… stay tuned.
