Skip to content

Instantly share code, notes, and snippets.

View william8th's full-sized avatar

William Heng william8th

  • william [at] williamheng [dot] com
  • London, United Kingdom
View GitHub Profile
@william8th
william8th / Date deserializer crash log
Created February 4, 2016 12:11
Date deserializer crash log for Outlook-SDK-Android
02-04 06:43:30.664 9206-12182/com.bjss.williamheng.office365poc W/System.err: com.google.gson.JsonSyntaxException: 2016-04-08
02-04 06:43:30.664 9206-12182/com.bjss.williamheng.office365poc W/System.err: at com.google.gson.internal.bind.DateTypeAdapter.deserializeToDate(DateTypeAdapter.java:81)
02-04 06:43:30.674 9206-12182/com.bjss.williamheng.office365poc W/System.err: at com.google.gson.internal.bind.DateTypeAdapter.read(DateTypeAdapter.java:66)
02-04 06:43:30.674 9206-12182/com.bjss.williamheng.office365poc W/System.err: at com.google.gson.internal.bind.DateTypeAdapter.read(DateTypeAdapter.java:41)
02-04 06:43:30.674 9206-12182/com.bjss.williamheng.office365poc W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:103)
02-04 06:43:30.674 9206-12182/com.bjss.williamheng.office365poc W/System.err: at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:196)
02-04 06:43:30.6
@william8th
william8th / WHYPerson.m
Created November 19, 2015 15:08
Objective-C Use ivars in init
@implementation WHYPerson
- (id)init {
self = [super init];
if (self) {
// It is recommended to use instance variables directly to initialise the object
_firstName = ...;
_lastName = ...;
_dateOfBirth = ...;
@william8th
william8th / WHYPerson.m
Last active November 19, 2015 15:25
Objective-C Instance variables
@implementation WHYPerson
...
// This is generated by the compiler (there is no need to put this line in your code)
@synthesize firstName; // Shorter version
// The above, according to Apple automatic naming convention for instance variables,
// is just doing this (add '_' prefix):
@synthesize firstName = _firstName; // Longer version
@william8th
william8th / WHYPerson.m
Created November 19, 2015 14:22
Objective-C @Property dot syntax
#import "WHYPerson.h"
...
@implmentation WHYPerson
...
- (NSString *)doSomething {
return [NSString stringWithFormat:@"Hello, %@", [self firstName]];
// Can also be done using dot syntax as it's just a wrapper around [self firstName]
@william8th
william8th / WHYPerson.h
Created November 19, 2015 14:17
Objective-C @Property
@interface WHYPerson : NSObject
@property (nonatomic) NSString *firstName;
@property (nonatomic) NSString *lastName;
@property (nonatomic) NSDate *dateOfBirth;
@property (nonatomic, readonly) NSString *fullName;
...
@end
@william8th
william8th / try-catch.m
Created October 13, 2015 08:38
iOS try-catch main
int main(int argc, char *argv[]) {
int retVal = -1;
@autoreleasepool {
@try {
retVal = UIApplicationMain(argc, argv, nil, nil);
}
@catch (NSException* exception) {
NSLog(@"Uncaught exception: %@", exception.description);
NSLog(@"Stack trace: %@", [exception callStackSymbols]);