Convert NSDate to JSON Date Format

It is often recommended to have dates formatted to JSON format when communicating with services. A JSON Date format normally looks like this:

2012-04-23T18:25:43.511Z

To Change a NSDate to JSON Date format, you can do the following:

NSDate *currDate = [NSDate date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init];
[dateFormatter setDateFormat:@"yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'SSS'Z'"];
NSString *dateString = [dateFormatter stringFromDate:currDate];
NSLog(@"%@",dateString);

The log would show the date in JSON Date format.

Change Font Color of UIBarButtonItem

To change UIBarButtonItem Font Color, you can set the TitleTextAttributes

_createBtn = [[UIBarButtonItem alloc] initWithTitle:@"Create" style:UIBarButtonItemStylePlain target:self action:@selector(createProject)];
[_createBtn setTitleTextAttributes:[NSDictionary[UIColor whiteColor], NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];

The UIBarButtonItem will be changed to white by setting the [UIColor whiteColor]

NSSNumber to NSInteger and NSInteger to NSNumber in Objective C

NSNumber to NSInteger and vice versa is easy. NSInteger is a primitive type and not an object type.

To get NSInteger from a NSNumber you can do the following:

anInteger = [aNumber intValue];

To get NSInteger from a NSNumber you can do the following:

aNumber = [aNumber numberWithInteger:anInteger];

Use meta tags to disable browser caching

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Sat, 13 Aug 1983 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

The above is a simple code to disable browser caching. The http-equiv attribute attempts to communicate with the browser regarding the page.

In the above code, the expires value tells the value that its information is old and get another. The pragma tells the browser not to cache.