* You are viewing the archive for the ‘Coding’ Category

Private API iPhone button creation

This is cool. Use the private API UIGlassButton in the iPhone simulator to create button images. Then import the images in your project and leave the private API call out.

Use NSUserDefaults to persist data between app runs

On the iPhone you generally want your application to start looking like it did when it was last run to give the user the impression your app is ready to pick up where it left off. NSUserDefaults provides an easy way to store your application’s settings between runs. Simply create an instance of NSUserDefaults and give it the key/value pairs you want it to save.

Storing an integer

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setInteger: myIntValue forKey: @"intValueKey"];
[prefs synchronize]; // writes modifications to disk

Reading it back in

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
int myIntValue = [prefs integerForKey: @"intValueKey"];

or more simply

int myIntValue = [[NSUserDefaults standardUserDefaults] integerForKey: … Continue Reading

NSNotificationCenter

I just learned about NSNotificationCenter. Any class in a program can send a notification message to the notification center, and all classes can listen to the center and respond to messages that apply to it. It’s kind of like a callback, but really not.

This is part of my code for implementing a custom keyboard in my iPhone app.

To send a notification named “keyboardDone” to all objects in your program.
[[NSNotificationCenter defaultCenter] postNotificationName: @”keyboardDone” object: nil];

To listen for the “keyboardDone” notification and call the “keyboardDoneObserver:” method when it’s received this can be added to your class’ init code.
[[NSNotificationCenter defaultCenter] addObserver: self … Continue Reading

Adding a code beautifier script to Xcode

Xcode’s re-indent command is pretty weak compared to the code reformatting built into other IDEs. It fixes the indentation at the beginning on each line, which makes a huge difference in code readability, but I don’t think it does anything else. In Eclipse and VS I’ve gotten used to being fairly lazy about being consistent with my spacing elsewhere and relying on their built in reformatting to clean it up for me. I wanted to change the way Xcode reformats code, since it’s easier to change tools than to break bad habits.

I spent some time searching for command line code … Continue Reading

Yahoo! UI Library

I don’t know if its because of their trying to compete with Google in the cool factor or what, but Yahoo has released some cool libraries and design pattern docs for creating interactive sites. I want to play with it sooo much right now, but I have a midtern in statistics tomorrow. Anyway, even if I don’t use their code I will be using it to learn how to do some cool things for a project I’m trying to figure out right now. Check out the Yahoo! UI Library and the Design Pattern Library.

Why do people switch to Linux?

I just came across an O’Reilly article about the reasons people switch to Linux, and how most people who switched did not do it out of hatred of Microsoft.

I’ve used Linux off and on since around 1996 or 1997, and am currently in one of the rare periods where there is no Linux box anywhere in my house. I think in a lot of ways it comes down to choosing the best tool for the job. In 1998 I built a dual-homed Redhat box to act as my firewall for my home network. At the time you … Continue Reading

Visual Studio Rots the Mind

If you’re a Windows programmer you should know who Charles Petzold is. Ten years ago his Programming Windows book was the best source of information on the win32 API, and now he has written a handful of .Net books. Apparently he’s come to the conclusion that Visual Studio Rots the Mind and his lengthy rant is excellent. Personally I don’t think this is Visual Studio’s fault, especially since in many ways Visual Studio is just keeping up with competitors like Eclipse, but is more a commentary on how current development tools encourage development to follow certain patterns that focus … Continue Reading

Startup School update!

A while back I posted about Paul Graham’s Startup School. Basically he helps groups of CS students start a company by giving them business advice and just enough money for them to rent a cheap office, buy bandwidth and some computer equipment, and buy a few months supply of Ramen Noodles and mac and cheese. The kids then spend a few months focusing on building a product and hopefully end up with a commercially viable company when they are done. I just came across a blog entry from a guy named Chris Sacca who attended one of the … Continue Reading

Coding paper

Oddly, the paper from my last post received a perfect score while the class average was only 88%. Now if I could be that lucky in my calculus class…

Coding as art - persuasion paper

This is a paper I just finished for my technical communications class. I argue that software development should be considered as a creative art like other forms of writing. It’s not especially well written as it was one of those “write a paper by next week in your spare time between work and other classes” type assignments and I had to throw it together in a few hours, but the main point is still valid. Maybe another argument for coding being creative is the fact I’m better at it than I am writing papers.

I think that the process of creating … Continue Reading

Page 1 of 212»