Skip to content

Instantly share code, notes, and snippets.

View steipete's full-sized avatar

Peter Steinberger steipete

View GitHub Profile
//
// MNDocumentController.h
// MindNodeTouch
//
// Created by Markus Müller on 22.12.08.
// Copyright 2008 Markus Müller. All rights reserved.
//
#import <Foundation/Foundation.h>
@class MNDocumentReference;
@steipete
steipete / DrawInsetBeveledRoundedRect.m
Created December 17, 2011 10:00
DrawInsetBeveledRoundedRect
void DrawInsetBeveledRoundedRect( CGContextRef context, CGRect rect, CGFloat radius, UIColor *fillColor )
{
//contract the bounds of the rectangle in to account for the stroke
CGRect drawRect = CGRectInset(rect, 1.0f, 1.0f);
//contract the height by 1 to account for the white bevel at the bottom
drawRect.size.height -= 1.0f;
//Save the current state so we don't persist anything beyond this operation
CGContextSaveGState(context);
@steipete
steipete / gist:1501754
Created December 20, 2011 14:34
Use Xcode to automatically set git hash
git=`sh /etc/profile; which git`
version=`$git describe --tags --always`
count=`$git rev-list --all |wc -l`
echo -e "#define GIT_VERSION $version\n#define GIT_COMMIT_COUNT $count" > InfoPlist.h
@steipete
steipete / gist:1501859
Created December 20, 2011 14:59
Info.plist settings
<key>CFBundleShortVersionString</key>
<string>GIT_VERSION</string>
<key>CFBundleVersion</key>
<string>GIT_COMMIT_COUNT</string>
@steipete
steipete / gist:1501869
Created December 20, 2011 15:03
Add InfoPlist.h to gitignore, check in once
echo InfoPlist.h >> .gitignore
# Note: With Xcode 4.3, it's no problem if the file doesn't exist before compilation.
# On Xcode 4.2, the file needs to be there. Either manually call "touch InfoPlist.h"
# or make an aggregate target that your main target depends on, adding the touch code there.
# postprocess Info.plist to include the git hash
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion `git rev-list --all |wc -l`" "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString `git describe --tags`" "${INSTALL_DIR}/Versions/${FMK_VERSION}/Resources/Info.plist"
@steipete
steipete / gist:1521975
Created December 26, 2011 19:26
Found this in some code... never seen code before that calls dealloc... does this work?
- (void) dealloc
{
// dealloc can trigger in background thread when the queued block is
// our last owner, and releases us on completion.
// Send the dealloc back to the main thread so we don't mess up UIKit.
if (dispatch_get_current_queue() != dispatch_get_main_queue()) {
__block id block_self = self; // don't auto-retain self!
dispatch_async(dispatch_get_main_queue(), ^{ [block_self dealloc]; });
} else {
[imageView release];
@steipete
steipete / PDFViewControllerSubclass.m
Last active October 1, 2015 18:07
simple example how to re-color the link annotations on PSPDFKit
// simple example how to re-color the link annotations
- (void)pdfViewController:(PSPDFViewController *)pdfController willShowAnnotationView:(UIView <PSPDFAnnotationView> *)annotationView onPageView:(PSPDFPageView *)pageView {
if ([annotationView isKindOfClass:[PSPDFLinkAnnotationView class]]) {
PSPDFLinkAnnotationView *linkAnnotation = (PSPDFLinkAnnotationView *)annotationView;
linkAnnotation.borderColor = [[UIColor blueColor] colorWithAlphaComponent:0.7f];
}
}
//// Bezier Drawing
UIBezierPath* bezierPath = [UIBezierPath bezierPath];
[bezierPath moveToPoint: CGPointMake(31, 30.5)];
[bezierPath addLineToPoint: CGPointMake(41, 22.5)];
[bezierPath addLineToPoint: CGPointMake(41, 36.5)];
[bezierPath addLineToPoint: CGPointMake(31, 30.5)];
[bezierPath closePath];
[[UIColor blackColor] setFill];
// Do I miss something obvious or is this the best way to detect if UIDocumentInteractionController is still open or not?
// (BOOL _isShowingOpenInMenu is in the class)
- (void)openInAction:(id)sender {
// do we need to dismiss a popover?
if ([self checkAndDismissPopoverForViewControllerClass:[UIDocumentInteractionController class] animated:YES]) {
return;
}