Show AppController.m syntax highlighted
#import "AppController.h"
#include <openssl/rand.h>
char* getDiceWd(int n); // I did not name this function. I have taste.
@implementation AppController
- (void)awakeFromNib {
[self rollAgainAction:nil];
}
- (IBAction)rollAgainAction:(id)sender_ {
NSMutableString *output = [NSMutableString string];
for (unsigned lineIndex = 0, lineCount = 19; lineIndex < lineCount; lineIndex++) {
uint16_t random[5];
int isRandom = RAND_bytes((uint8_t*)&random, sizeof(random));
if (isRandom) {
[output appendFormat:[NSString stringWithFormat:@"%s %s %s %s %s\n",
getDiceWd(random[0]),
getDiceWd(random[1]),
getDiceWd(random[2]),
getDiceWd(random[3]),
getDiceWd(random[4])]];
} else {
[output appendString:@"<not enough entropy>\n"];
}
}
[output deleteCharactersInRange:NSMakeRange([output length]-1,1)];
[outputView setString:output];
}
@end
See more files for this project here