Bugs only exist in software because we as developers introduce them. We don't mean to introduce them however there is no denying that they exist and that we've all come across them at some point in the software that we use. Thankfully there are a range of testing techniques that we can empl…
I've been dealing recently a lot with OCMock [http://ocmock.org/] and while is great there is some draw backs for it. The major one that I had was when I was writing integration tests for a legacy library that we have. I needed to override a method of an object that was inside a method that I wa…
The other day I was developing a dictionary view controller that consisted of a UITableView and an NSArray (approx. 4000 elements) holding the data to be shown. As the elements were of varying lengths I had implemented the delegate method: - (CGFloat)tableView:(UITableView *)tableViewheightForRowA…
If you have ever seen the following pattern and wondered why: NSObject *newObject = [[object retain] autorelease]; return newObject; Well wonder no more! The reason behind this retain/autorelease pattern is to ensure that the "object" will not be destroyed until the caller's autore…
The other day I was looking around for a code snippet for hashing a string using SHA1 but couldn't find one so..... - (NSString *)generateHashValueForString:(NSString *)toBeHashed { NSString *hashedString = nil; NSString *stringToBeHashed = [NSString stringWithFormat:@"%@%@",…
The other day I had to resubmit my CSR file to the iOS Provisioning Portal as I was moving mac (and no longer had access to my old mac to move credentials across). Having did this before (on this mac in fact) I thought it would be a straight forward task: 1. Open Keychain Access 2. Select "R…
When writing a class or method, the way that I view other classes that want to use my class is as my enemies (even if I’m writing the other classes!). That might should dramatic but I take the approach that what ever is going to use my class might not properly understand the class and feed it junk.…
I sometimes see code where the delegate has a type of NSObject rather than id: id<CustomDelegate> delegate; NSObject<CustomDelegate> *delegate; and when asked "why" I'm always told the same answer: "So that when using the delegate I can use the performSelector metho…
I ran across the scenario where I wanted to disable the paste functionality on some textfield in my application. I've did this many times before and quickly added the following method to my viewcontroller: -(BOOL)canPerformAction:(SEL)action withSender:(id)sender { if ([UIMenuController sh…