This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int i; | |
NSMutableString *string = [NSMutableString string]; | |
for (i = 32; i < 55296; i++) { | |
if (!(i % 10)) [string appendString:@"\n"]; | |
[string appendFormat:@"(%04X:%i)%C, ", i, i, i]; | |
} | |
NSLog(@"%@", string); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
-(BOOL) respondsToSelector:(SEL)aSelector { | |
printf("SELECTOR: %s\n", [NSStringFromSelector(aSelector) UTF8String]); | |
return [super respondsToSelector:aSelector]; | |
} | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
#define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__]) | |
#define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__] | |
#else | |
#define DLog(...) do { } while (0) | |
#define ALog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__]) | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation UIImage (Extras) | |
#pragma mark - | |
#pragma mark Scale and crop image | |
- (UIImage*)imageByScalingAndCroppingForSize:(CGSize)targetSize | |
{ | |
UIImage *sourceImage = self; | |
UIImage *newImage = nil; | |
CGSize imageSize = sourceImage.size; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// SynthesizeSingleton.h | |
// CocoaWithLove | |
// | |
// Created by Matt Gallagher on 20/10/08. | |
// Copyright 2009 Matt Gallagher. All rights reserved. | |
// | |
// Permission is given to use this source code file without charge in any | |
// project, commercial or otherwise, entirely at your risk, with the condition | |
// that any redistribution (in part or whole) of source code must retain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function OnGUI() { | |
var screenScale: float = Screen.width / 480.0; | |
var scaledMatrix: Matrix4x4 = Matrix4x4.identity.Scale(Vector3(screenScale,screenScale,screenScale)); | |
GUI.matrix = scaledMatrix; | |
// then do the rest of your GUI as per normal, using the 480x320 screen size you had for your standard res iPhone app | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Here are some regex script use in vim to help you translate objc code to cpp version.It is not perfect since it just could translate nearly 80% code correctly. | |
how to use it : | |
1.open mac terminal | |
2.run vim open the objec-code file | |
3.copy the regex below | |
4.click the edit->paste on the terminal menu | |
5.prees enter key | |
6.repeat step 4 - 5 seviral times | |
7.done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
KEYWORDS="TODO|FIXME|\?\?\?:|\!\!\!:" | |
find ${SRCROOT} \( -name "*.h" -or -name "*.m" \) -print0 | \ | |
xargs -0 egrep --with-filename --line-number --only-matching "($KEYWORDS).*\$" | \ | |
perl -p -e "s/($KEYWORDS)/ warning: \$1/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (UIImage *)convertImageToGrayScale:(UIImage *)image | |
{ | |
// Create image rectangle with current image width/height | |
CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height); | |
// Grayscale color space | |
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); | |
// Create bitmap content with current image size and grayscale colorspace | |
CGContextRef context = CGBitmapContextCreate(nil, image.size.width, image.size.height, 8, 0, colorSpace, kCGImageAlphaNone); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <sys/utsname.h> | |
enum { | |
MODEL_IPHONE_SIMULATOR, | |
MODEL_IPOD_TOUCH, | |
MODEL_IPHONE, | |
MODEL_IPHONE_3G | |
}; | |
@interface DeviceDetection : NSObject |
OlderNewer