Small notes
Some lessons I learnt the past few days:
Cocos2D: Don't load heavy resources in the init method. This will crash the app. Instead, load them in a scheduled method.
Box2D: Don't change scene while world is locked (when detecting and responding to touch). This will cause a memory leak. Instead, change the scene in an scheduled method.
Android: The method insert in SQLiteDatabase doesn't throw exception. It does throw exception and print the stack trace but it's internally handled by that method and the exception won't by caught by the try catch block. If you need to catch exception, use insertOrThrow instead.
Code snippet to pad numbers with zero:
Cocos2D: Don't load heavy resources in the init method. This will crash the app. Instead, load them in a scheduled method.
Box2D: Don't change scene while world is locked (when detecting and responding to touch). This will cause a memory leak. Instead, change the scene in an scheduled method.
Android: The method insert in SQLiteDatabase doesn't throw exception. It does throw exception and print the stack trace but it's internally handled by that method and the exception won't by caught by the try catch block. If you need to catch exception, use insertOrThrow instead.
Code snippet to pad numbers with zero:
NSString *paddingFormat = [[NSString stringWithFormat:@"time\n%%0%dd:%%0%dd", 2, 2] retain];
NSString *paddedNumber = [NSString stringWithFormat:paddingFormat, 0, 0];
Result:
time
00:00
0 komentar:
Posting Komentar