I am having a bit of a play with the cocos2d game engine for iPhone and encountered a very strange error in the console - I don’t believe it’s at all related to the game engine itself, so it’s just coincidence that I was trying something new out.
error while killing target (killing anyway): warning: error on line 1987 of “/SourceCache/gdb/gdb-962/src/gdb/macosx/macosx-nat-inferior.c” in function “macosx_kill_inferior_safe”: (os/kern) failure (0x5x)
I figured out that it had to do with definition of a selector… Naughty code below.
Getting and setting user preferences on iPhone is pretty darn easy. I was looking for a way to automagically store a users email address between different application sessions, and found the linked tutorial immensely helpful (iphonedevelopertips.com).
I needed to store a string (NSString object actually) however, and the tutorial didn’t help me with that. The NSUserDefaults object has dedicated methods for storing and retrieving BOOL, float, and NSInteger values. It also has a setObject:forKey: method - which is what I ended up using. The setObject method handles data of types NSData, NSString, NSDate, NSArray or NSDictitionary - making it incredibly useful indeed.
#import "Preferences.h"@implementationPreferences/*-------------------------------------------* Return the users default email address*-------------------------------------------*/+(NSString*)emailAddress{NSString*returnValue;// If preference existsif([[NSUserDefaultsstandardUserDefaults]stringForKey:kPreferencesEmailAddress]){returnValue=[[NSUserDefaultsstandardUserDefaults]stringForKey:kPreferencesEmailAddress];}else{returnValue=@"";}returnreturnValue;}/*-------------------------------------------* Write preferences to system*-------------------------------------------*/+(BOOL)setPreferences:(NSString*)emailAddress{// Set values[[NSUserDefaultsstandardUserDefaults]setObject:emailAddressforKey:kPreferencesEmailAddress];// Return the results of attempting to write the preferences to systemreturn[[NSUserDefaultsstandardUserDefaults]synchronize];}@end
kPreferencesEmailAddress is a constant I’ve defined with the key value of the users email address. It just makes sure I don’t mistype anything.
Key (only) differences between my code and the code at iphonedevelopertips.com are the use of the objectForKey method to set the NSString value, and stringForKey to retrieve the object and cast it to a NSString object.
Went into Woolies here in Reading a couple of days ago to see what was left on the shelves. They truly are selling everything. People were literally buying the shelves the remaining products were sitting on. I also saw them offering the tills for £150 - considered getting one so I could play shopkeeper, but no.
Some pics of the carnage
Pretty much everything was gone. Apart from the below fella’s book. Give it up! People won’t even buy your work when it’s heavily discounted.
Poor Cliff.
That’s not the end of Woolworths for those in the southern hemisphere however. The brand lives on as a supermarket - I do remember Woolworths being a cheap department/variety store in New Zealand when I was very young, but it transitioned to a supermarket there many years ago.
I won’t miss Woolworths. I only ever bought 1 pair of gardening gloves and a can of “V” from it.
I received a package I ordered from Zazzle today and it contained some discount vouchers that I won’t be using. Codes below - tell me if they don’t work so I can update the post to show they are gone.
$10 (USD I assume) orders of over $10 or more - expiring 31st Dec 2008 - ZAZZLE10GIFTAYJTRYRM and ZAZZLE10GIFTDFWCINBI
$5 off purchase of $50 or more (I reckon this is multi-use) expiring 18th Jan 2009 - ZAZZLEWINTER
I was having some issues with Memory Management and dealloc’ing objects (and subsequently crashing software) and found the following resources very useful:
If you create an object it’s your responsibility to release it
If you want to own an object or use and object returned from another object you should retain it
Don’t release an object you didn’t create or own
Now I remember why I like programming languages that take memory management out of my hands. Last time I touched memory management was at university, and it was a pain then too.
Good thing is that Objective-C/Cocoa has those simple rules/conventions to follow. Memory Management is not onerous on the mac/iPhone, so I can’t complain too much.
LinkedIn have released an iPhone app. I’m a big fan and user of their app, and I think keeping up to date has just become a lot easier with this iPhone app.
I had a very confusing situation today with a multipart form that was for uploading a picture to a new web service I’m working on.
In Safari the form upload worked. Even in Internet Explorer 6 the form upload worked (after I fixed the dodgy MIME-type that IE passes through for JPG images - image/pjpeg for those interested).
The form I was trying to submit had the multipart attribute set correctly, and also had some javascript to disable the file selection, form submission button, and show a spinner to indicate that something is happening, and they don’t try and submit the file twice if they’re sending in a large image.
My submit tag orginally looked like this (Ruby on Rails)
What I find particularly confusing about this is that everything I read on the “return false;” statement leads me to believe that this form should not be submitted - however - return true does not work (500 Internal Server Error returned). But what the hey - it works.