Ignoring certificate errors with NSURLConnection

You could simply ignore the invalid certificate if you are not sending any sensitive information. This article describes how you could do that. Here is an example implementation by Alexandre Colucci for one of the methods described in that article. Essentially you want to define a dummy interface just above the @implementation: @interface NSURLRequest (DummyInterface) … Read more

How do I draw an NSString at an angle?

Here’s an example that uses a transform to rotate the drawing context. Essentially it’s just like setting a color or shadow, just make sure to use -concat instead of -set. CGFloat rotateDeg = 4.0f; NSAffineTransform *rotate = [[NSAffineTransform alloc] init]; [rotate rotateByDegrees:rotateDeg]; [rotate concat]; // Lock focus if needed and draw strings, images here. [rotate … Read more

NSNumber of seconds to Hours, minutes, seconds

Have you tried creating an NSDate from that and printing that using an NSDateFormatter? NSDate *date = [NSDate dateWithTimeIntervalSince1970:[theNumber doubleValue]]; NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@”HH:mm:ss”]; NSLog(@”%@”, [formatter stringFromDate:date]); [formatter release]; If you need the individual values for hours, minutes, and seconds, use NSDateComponents as suggested by nall. The above won’t print the … Read more

Is there a way of getting a Mac’s icon given its model number?

Mac App Store safe Manually map model identifier to icon name and then use e.g [[NSWorkspace sharedWorkspace] iconForFileType:@”com.apple.macbookair”]; or [NSImage imageNamed:NSImageNameComputer] If you need higher resolution than imageNamed provides use OSType code = UTGetOSTypeFromString((CFStringRef)CFSTR(“root”)); NSImage *computer = [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(code)]; where “root” string is from IconsCore.h header file (kComputer). Copy this plist to get the … Read more

NSDate between two given NSDates

This isn’t perfect, but you could use [NSDate compare:] to check your date against both boundaries: NSDate *firstDate = … NSDate *secondDate = … NSDate *myDate = [NSDate date]; switch ([myDate compare:firstDate]) { case NSOrderedAscending: NSLog(@”myDate is older”); // do something break; case NSOrderedSame: NSLog(@”myDate is the same as firstDate”); // do something break; case … Read more