Create a table of contents from a pdf file

Something like this might help you get started: NSURL *documentURL = …; // URL to file or http resource etc. CGPDFDocumentRef pdfDocument = CGPDFDocumentCreateWithURL((CFURLRef)documentURL); CGPDFDictionaryRef pdfDocDictionary = CGPDFDocumentGetCatalog(pdfDocument); // loop through dictionary… CGPDFDictionaryApplyFunction(pdfDocDictionary, ListDictionaryObjects, NULL); CGPDFDocumentRelease(pdfDocument); … void ListDictionaryObjects (const char *key, CGPDFObjectRef object, void *info) { NSLog(“key: %s”, key); CGPDFObjectType type = CGPDFObjectGetType(object); switch … Read more

UIView with a Dashed line

Check UIBezierPath setLineDash:count:phase: method: – (void)setLineDash:(const CGFloat *)pattern count:(NSInteger)count phase:(CGFloat)phase` method. This allows you to draw dashed lines. First add a CAShapeLayer. Add it as sublayer to your UIView. It has a path property. Now make an object of UIBezierPath. Draw the line using setLineDash. For example: UIBezierPath *path = [UIBezierPath bezierPath]; //draw a line … Read more

How to map atan2() to degrees 0-360

Solution using Modulo A simple solution that catches all cases. degrees = (degrees + 360) % 360; // +360 for implementations where mod returns negative numbers Explanation Positive: 1 to 180 If you mod any positive number between 1 and 180 by 360, you will get the exact same number you put in. Mod here … Read more