Hi, Just i dont have so much time right now, here some snippets I collected for myself over the last couple of weeks
1.
Should u use Wireshark and dont get it work, try this to find the Interfaces
sudo chmod 644 /dev/bpf*
2.
MOUNT a ISO within yout MAC OSX
hdiutil mount image.iso
3.
Dump Wifi Data
sudo tcpdump -i en1 -v // to dump all wifi data
sudo tcpdump -i en0 -v // to dump all ethernet data
4.
Create a Screenshot programmaticly in your iPhone
IPhone screenshot
CGImageRef UIGetScreenImage();
5.
MySQL TRICK
update cdent_clients set fachcode = replace(fachcode, “kfo”, “kf”)
= replace all ‘kfo’ in fachcode into “kf”
update cdent_clients set fachcode = replace(fachcode, “.”, “,”)
6.
Convert WAV to CAF
afconvert -f caff -d LEI16@44100 -c 1 laugh3.wav laugh3.caf
CONVERT WAV TO CAF
find ./ -type f -exec grep -l ‘hello’ {} \;
7.
set text with two different strings or chars
galaxydesc.text = [NSString stringWithFormat:@"%@ %s", @"Actual Image: ", picdesc ];
8.
Make GLOBAL int or other Variables
place your wished global Variable in a external .h and import in each .m where you need
or place it in you _prefix.pch file which is imported to any .m automaticly
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
extern int firsttime;
#endif
important write “extern” before you declaration!
Than in each .m just declare it as usual with example
int firsttime = 0;
9.
Draw Image in your View
NSString* imageFileName = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@”redarea.png”];
CGDataProviderRef provider = CGDataProviderCreateWithFilename([imageFileName UTF8String]);
CGImageRef image = CGImageCreateWithPNGDataProvider(provider, NULL, true, kCGRenderingIntentDefault);
CGDataProviderRelease(provider);
// Draw image
CGContextSaveGState(context);
CGContextTranslateCTM(context, 0, 320); // this is to rotate the image if it is upside down
CGContextScaleCTM(context, 1.0, -1.0); // part II of rotation
CGContextDrawImage(context, CGRectMake(0, 0, 480, 320), image);
CGContextRestoreGState(context);
CGImageRelease(image);
10.
DISABLE SLEEP MODE
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Disable Sleep Mode
application.idleTimerDisabled = YES;
// Override point for customization after application launch
[window makeKeyAndVisible];
}
11.
Debugging with NSLOG
int myNumber = 3;
NSString *myText = @”Dog”;
NSLog(“My number is %i and my text is %@.”, myNumber,myText);
While
%i, %d signed integer
%u unsigned integer
%f float
%@ object
12.
//Change Status Bar Orientation
[UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
//Activity Indicator in Status Bar
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO; // or YES
//Show or Hide Status Bar
[self.navigationController setNavigationBarHidden:TRUE animated:NO]; // or NO to Hide
or in Case [[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];
13.
//Paint a Line in a View
- (void)drawRect:(CGRect)rect {
// Paint LINE
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
UIColor *color= [UIColor blueColor];
CGContextSetStrokeColorWithColor(context, color.CGColor);
CGContextMoveToPoint(context, 10.0,10.0 );
CGContextAddLineToPoint(context, a,100.0);
CGContextStrokePath(context);
}
14.
//Place a Text in a View
- (void)drawRect:(CGRect)rect {
// Set Text
CGAffineTransform xform = CGAffineTransformMake(1.0, 0.0,0.0, -1.0,0.0, 0.0);
CGContextSelectFont(context, “Arial”, 24, kCGEncodingMacRoman);
CGContextSetTextMatrix(context, xform);
//CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetRGBFillColor(context, 0, 0, 0, 1);
CGContextShowTextAtPoint(context, a,21, text, strlen(text)-1);
//[color release];
}
15.
//Update your drawRect by Timer
Set a Time Call in your Startup:
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
-(void) onTimer {
// Code what you like to update. For example: a++;
[self setNeedsDisplay];
}

Loading ...