iPhone: Helpful Classes or extended Subclasses which should have been in the SDK
- by disp
This is more a community sharing post than a real question.
In my iPhone OS projects I'm always importing a helper class with helpful methods which I can use for about every project.
So I thought it might be a good idea, if everyone shares some of their favorite methods, which should have been in everyones toolcase.
I'll start with an extension of the NSString class, so I can make strings with dates on the fly providing format and locale. Maybe someone can find some need in this.
@implementation NSString (DateHelper)
+(NSString *) stringWithDate:(NSDate*)date withFormat:(NSString *)format withLocaleIdent:(NSString*)localeString{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//For example @"de-DE", or @"en-US"
NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:localeString];
[dateFormatter setLocale:locale];
// For example @"HH:mm"
[dateFormatter setDateFormat:format];
NSString *string = [dateFormatter stringFromDate:date];
[dateFormatter release];
[locale release];
return string;
}
@end
I'd love to see some of your tools.