Skip to main content

Posts

Showing posts from November, 2010

Date Formatter

Objective -C  Date Formatter Examples - stringFromDate For Example:  Saturday November 8, 2008 : NSDate *today = [NSDate date]; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"EEEE MMMM d, YYYY"]; NSString *dateString = [dateFormat stringFromDate:today]; [dateFormat release]; Here’s another example showing the current time 9:20 AM, PST : NSDate *today = [NSDate date]; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"h:mm a, zzz"]; NSString *dateString = [dateFormat stringFromDate:today]; [dateFormat release];

Device Type

#include #include - (NSString *) platform{     size_t size;     sysctlbyname("hw.machine", NULL, &size, NULL, 0);     char *machine = malloc(size);     sysctlbyname("hw.machine", machine, &size, NULL, 0);     NSString *platform = [NSString stringWithCString:machine];     free(machine);     return platform; } - ( NSString *) platformString {     NSString * platform = [ self platform ];     if ([ platform isEqualToString :@ "iPhone1,1" ])     return @ "iPhone 1G" ;     if ([ platform isEqualToString :@ "iPhone1,2" ])     return @ "iPhone 3G" ;     if ([ platform isEqualToString :@ "iPhone2,1" ])     return @ "iPhone 3GS" ;     if ([ platform isEqualToString :@ "iPhone3,1" ])     return @ "iPhone 4" ;     if ([ platform isEqualToString :@ ...